• 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

"DecimalFormat"

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In my program I have a double variable, which displays result as "1.436555578". I want to restrict the display to two decimal places like "1.43".
How to do so ? Please illustrate with small code.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rohit,
Take a look at the following Method. The method takes a given prices and formats it.

Hope this helps.
Thanks,
Tom
(edited by Cindy to format code)
[ June 13, 2002: Message edited by: Cindy Glass ]
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had the same question not too long ago. Here is the advice I received and how I remedied the problem. Hope this helps.
http://www.coderanch.com/t/391683/java/java/formatting-decimal-spaces
-Brock
 
Rohit Prakash Khare
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all of you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!