A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
Beginning Java
Author
rounding a double to two decimals
Nasser Aboobaker
Ranch Hand
Joined: Dec 06, 2000
Posts: 104
posted
Jan 27, 2002 20:03:00
0
Hi,
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.
Nasser
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9033
10
posted
Jan 27, 2002 22:31:00
0
You could multiply the double by 100, round it, and then divide by 100.0 That's one way.
JavaBeginnersFaq
"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:
http://aspose.com/file-tools
subject: rounding a double to two decimals
Similar Threads
Math class
How to round a double to two decimal place?
Rounding Doubles to Two Decimal Places
One Question Quiz for Newcomers
rounding a fraction+time
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter