Roel Appel

Greenhorn
+ Follow
since Jun 23, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Roel Appel

Hello all,

I'm developing for BlackBerry 4.2.1 and i'm facing a difficult problem. I want to convert a float to String without the scientific notation. I'm using Float#toString(float f) but it gives an scientific notation back. According to the javadoc, "If m is less than 10-3 or not less than 107, then it is represented in so-called "computerized scientific notation."".

Another problem is there's no NumberFormat class available either.

So i started writing my own formatter, the requirement is formatting floating point numbers with a maximum precision of 10. This is what i have so far:





This works but not for big floating point numbers because of line 24. Here i try to calculate the remainder.
I do this by subtracting the float value with the int value. But first multiply it with a large number because subtracting float numbers is imprecise. The problem is the multiplication with the large number (pow) which can exceed the maximum long size.

Anyway, some help with setting the remainder in the StringBuffer would be appreciated.

Thanks in advance.
14 years ago