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

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

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

ios - CFRelease causing crash in iPad application -