• Post Reply Bookmark Topic Watch Topic
  • New Topic

Formatting a double field  RSS feed

 
B West
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried for a while to do this and I'm having a very hard time. Is there a way to take a double field and insert a decimal into it.

for instance:

double = 1500 covert to 15.00


I realize I could convert to string and substring and all that, I thought there might be a slicker way to do it.

Anybody have any ideas?

Thanks in advance!
BW
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Converting 1500 to 15.00 means dividing by 100. You can work out how to print different numbers of figures with the % tags (see the Java Tutorials and the Formatter class), or one of the formatting classes eg DecimalFormat. Most people using Java5+ would use the % tags.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!