aspose file tools
The moose likes Beginning Java and the fly likes Rounding of float value Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Rounding of float value" Watch "Rounding of float value" New topic
Author

Rounding of float value

AnilPrakash Raju
Ranch Hand

Joined: Jul 26, 2004
Posts: 137
Hi,

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

thanks

Anil
Ariel Ortiz
Ranch Hand

Joined: May 14, 2004
Posts: 121
Try the Math.round() method.

...Ariel
AnilPrakash Raju
Ranch Hand

Joined: Jul 26, 2004
Posts: 137
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
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
Try java.text.DecimalFormat


[ July 21, 2005: Message edited by: Mani Ram ]

Mani
Quaerendo Invenietis
AnilPrakash Raju
Ranch Hand

Joined: Jul 26, 2004
Posts: 137
Thanks Mani




Anil
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
Hi

Try this code for rounding off your float value


bye for now
sat
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Rounding of float value
 
Similar Threads
string to float conversion round off problem
Float wrapper takes double primitive implicitly.
Tech Word Game
WA #2 ..... word association
question on wrapper class