This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

floating point precision

 
george justin
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
David Weitzman
Ranch Hand
Posts: 1365
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nathan, besides using String manipulation
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic