Possible Duplicate:
Clear trailing 0’s on a double?
Limit a double to two decimal places without trailing zeros
I have a field where a user enters a number via the keyboard (decimal numberpad), for example, "1.5". This is stored as a double.
Later when I allow the user to edit the field and present the number it is shown as "1.500000" which I don't want.
What's the most efficient method to remove these trailing zeros? I can't round the number to a specific number of decimal points because the user can enter any number they wish and it has to stay this way (it's a unit of weight).
I could split the number into an array of characters and iterate over in reverse popping off the zeros until I hit anything above 0 but I thought/hoped there was something a little more efficient in Objective C?
Thanks!