wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes floating point precision Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "floating point precision" Watch "floating point precision" New topic
Author

floating point precision

george justin
Greenhorn

Joined: Jul 31, 2001
Posts: 25
Hi,
COULD SOMWEONE P-OSSIBLY TELL ME HOW TO convert floating point data to a precision of 2 decimal points....urgent..pleeeeeeez.
besides using String manipulation....
thanx.
george
Bill Tripper
Greenhorn

Joined: May 30, 2001
Posts: 24
Theres probably a function to do this which I couldn't find, but how about:
x = Math.round(x * 100) / 100.0;
If x is a double, this will round it to 2 decimal places.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Here's the function Bill couldn't find: setMaximumFractionDigits( int ) in the java.text.DecimalFormat class...

See this post for more details...

- Nate
[This message has been edited by Nathan Pruett (edited August 23, 2001).]


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
Nathan, besides using String manipulation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: floating point precision
 
Similar Threads
literals
Confused about the Number datatype
Sinking in float
Double literal
multiplication using double type variables