This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Please help! Urgent!  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Is there any way in Java for rounding of the numbers to two digits. For example the number "2.901614044112919" should be like "2.91" or "2.92". I used the Math functions "ceil,round & floor", does not seems to be helping me to get the desired the result.
Please reply ASAP.
Appreciate yr help.
Thanks in advance
Regards
Krishna
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this:
double val = 2.901614044112919;
DecimalFormat formatter = new DecimalFormat("#.##");
String output = formatter(val);
System.out.println("output: " + output);
check out this: http://java.sun.com/docs/books/tutorials/il8n/format/decimalFormat.html
Hope this helps!
Good luck
 
Krishna Nagesh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mindy!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!