File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Formatting floating point numbers

 
O. Ziggy
Ranch Hand
Posts: 430
Android Debian VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following sample code:



Prints out 2122.4

The format i specified for the above result shows that i asked for one decimal point and 1 character long for the width. I can see the one decimal point (i.e. .4) but why did the specified width not work?
 
Sebanti Sanyal
Ranch Hand
Posts: 58
C++ Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you specify is the minimum no. of characters to print. Here the integral part contains 4 characters and along with the fractional part, there are 6 characters to print. Increase the width to 7 to see the difference.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic