File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
rounding a double to two decimals
Joined: Dec 06, 2000
Jan 27, 2002 20:03:00
Can some one tell me how to round a double number to nearest two decimal. Math.round method just round it into long.
Thanks in advance.
Marilyn de Queiroz
Joined: Jul 22, 2000
Jan 27, 2002 22:31:00
You could multiply the double by 100, round it, and then divide by 100.0 That's one way.
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I agree. Here's the link:
subject: rounding a double to two decimals
One Question Quiz for Newcomers
How to round a double to two decimal place?
rounding a fraction+time
Rounding Doubles to Two Decimal Places
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013