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

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -