Well, I am using %f
for displaying float values in my string. However, the values are too accurate (around 6 decimal digits after the point). I'd like to only display 1 decimal. But how?
Asked
Active
Viewed 1.5k times
-2

Saturn
- 17,888
- 49
- 145
- 271
-
3Was there even an *attempt* to find some documentation first? – Sep 10 '11 at 01:42
-
possible duplicate of [how to set the float value to two decimal number in objective C](http://stackoverflow.com/questions/560517/how-to-set-the-float-value-to-two-decimal-number-in-objective-c) or [How to format float number](http://stackoverflow.com/questions/2134260/how-to-format-float-number-objective-c) @pst – jscs Sep 10 '11 at 01:50
-
@pst: No, there wasn't any attempt as far as I can recall. Why? – Saturn Dec 16 '12 at 21:42
4 Answers
4
NSLog(@"%0.1f", floatThing);
I think that should work. For more decimals change 0.1 to 0.2, 0.3, 0.4 ... etc.

Dair
- 15,910
- 9
- 62
- 107