• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

changing the decimal format representation

 
Mohit Sinha
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I have a requirement wherein I need to change the way decimal place values are displayed

Currently my calculation yields double value .05 or -.03 which i want to represent something like this 1.05 or .97 respectively.

Let me know the best approach.


Thanks,

 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15356
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you just want to print the number plus one? Then just add 1 to the number before displaying it.

Or is your question about actually formatting numbers? There are several ways to do that; for example using class java.text.DecimalFormat, or by using System.out.printf():

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic