math - How to Round 46.565 to 46.57 in Java? (no ceiling) -
this question has answer here:
- how round number n decimal places in java 28 answers
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
Post a Comment