Hai all, I have a float value in my java program which is used to calculate percentage. And i have to round that value to two decimal places. The conversion i am expecting is as follows 12.3476 to 12.35 12.9988 to 13.00 I tried with round(),number2str supported by Tutil class and some jstl tags also. But answer is not like i am expecting. Is there any other API classes to do this,Or any other method? Please help me and do reply me immediately....
If what you want to do is to print out the value, rounded to 2 d.p. then the example already given, using NumberFormat, is probably the right thing to do.
On the other hand, if you want to obtain a float value, rounded to 2 d.p. then converting to text and back might work but would be rather inefficient.
An alternative might be to multiply your float by 100.0, cast it to an int and consider it to be in "hundredths".
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P