• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing shorter doubles

 
Daniel Searson
Ranch Hand
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When printing a double value using Double.toString(), they always come out with about 8 digits shown. I can't find any way to make the method print shorter versions (say, to 4 decimal places). Is there any way to achieve this, short of writing my own string formatting method? (which I want to avoid...)
Thanks.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the DecimalFormat class - it should offer you most everything that you might need.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic