• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Quick question

 
joew weakers
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there. This is a really quick one. If I have a float value 3.5711762E-6,
how do I just return the number to four decimal places, i.e. 3.5718. Cheers, Joe
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably have to convert it to a string and then use subString to get the right number of digits. If you were to use BigDecimal I think it has methods that do that for you.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on how you want to use the rounded version. If you are simply displaying the value, then you should use the NumerFormat class. If you need to round a number for calculations, you should look at the round() method in the Math class.

HTH

Layne
[ February 28, 2005: Message edited by: Layne Lund ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic