math - How to Round 46.565 to 46.57 in Java? (no ceiling) -


this question has answer here:

i've been using math.round , seemed fine until noticed number ended in "5" wasn't rounded.

double roundtotal = math.round(total * 100.0) / 100.0; 

which rounds 2 decimal places, doesn't round 46.565 46.57 example

can help?

you this:

double roundtotal = ((int)((total*100.0)+0.5)) / 100.0; 

Comments

Popular posts from this blog

Issues changing the value of an element in an array in matlab -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

vb.net - Alternative to the T-SQL AS keyword -