• Post Reply Bookmark Topic Watch Topic
  • New Topic

Float  RSS feed

 
Pradeep Chandrasekharan Nair
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there any methods in Float class to set the maximum decimal points.
 
eammon bannon
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.
In days gone by there used to be setPrecision methods for floats and doubles (JSDK1.0), but these are long gone. Use a NumberFormat to set the precision at display time.
 
Byron Estes
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you allowed setting precision in the internal representation of the number and not just how it is displayed you run into all kinds of nasty rounding issues, because rounding might be employed multiple times over the course of a calculation sequence and not just once at the end.
It could also play havoc with portability and distributed processing, part of the power of java is that things like number formats are common across all machines. An integer is always "x" bits, etc.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!