The output of the following two lines seem to show that NSString's stringWithFormat statement does not round numbers consistently. It seems to round up correctly from 0.75 to 0.8. But it rounds 0.25 down to 0.2. Here is the code.
NSString *sRoundedScore = [NSString stringWithFormat:@"%.1f", fScore];
NSLog(@"\r\n score before rounding: %f, rounded score: %@", fScore, sRoundedScore);
When fScore is assigned to be 0.25, the output is:
score before rounding: 0.250000, rounded score: 0.2
When fScore is assigned to be 0.75, the output is:
score before rounding: 0.750000, rounded score: 0.8
I had to begin using NSNumberFormatter to get this to round consistently up. Why though does stringWithFormat produce this variation in results?