how to round a number to 2 decimals [duplicate]

This question already has an answer here:

Round a double to 2 decimal places [duplicate]

13 answers

So I have a number that is about 42.000005 and I tried to round it to 2 decimals in java. I have already tried double result=Math.round(farenheit*100)/100D; and String.format("%.3f", result);

Both of them give me 42.0. Is there a way to get 42.00

Thanks so much!!!

double farenheit= a*(9/5.0) -459.67;

double result=Math.round(farenheit*100)/100D;

String.format("%.3f", result);...

Read More »

By: StackOverFlow - 6 days ago

Related Posts