View Full Version : NSDecimalNumber doubleValue -- conversion precision?

Aug 31, 2008, 04:20 PM
I'm getting very small conversion errors from doubleValue when the receiver is an NSDecimalNumber or an NSString... for example:

NSDecimalNumber *dNumber = [NSDecimalNumber decimalNumberWithString:tmpString];
double tmpValue = [dNumber doubleValue];

If the input string (tmpString) is "3.4", the output of tmpValue is 3.399999999999

Is there anything that can be done? NSScanner does the same thing, other input values have precision errors where the precision of a double comes into play, but I would not have expected these results.

Any insight is appreciated!!!