It looks like you're new here. If you want to get involved, click one of these buttons!
marktwo wrote: »
Floating-point arithmetic (addition, subtraction, etc...) is imprecise:
1.0 + 0.1 does not equal 1.1, but 1.09999999999999999.
The same goes for doubles too.
If you need exact values, use integers.
int tenths = 724; //Represents 72.4
- (NSString *) stringFromTenths: (int) tenthsValue;
return [NSString stringWithFormat: @%d.%d, tenthsValue/10, tenthsValue %10];
NSLog(@tenthsValue = %@", [self stringFromTenths: tenths]);