• Post Reply Bookmark Topic Watch Topic
  • New Topic

Rounding of float value  RSS feed

 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

how can i rouud off a float value eg. 7.39999 to 7.4

thanks

Anil
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the Math.round() method.

...Ariel
 
AnilPrakash Raju
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ariel but Math.round() returns an int.

is there any function that i can use to specify how many decimal points i want?

thanks

Anil
 
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try java.text.DecimalFormat


[ July 21, 2005: Message edited by: Mani Ram ]
 
AnilPrakash Raju
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mani




Anil
 
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Try this code for rounding off your float value


bye for now
sat
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!