Issue when transform NSNumber(Double) to String
Closed this issue · 4 comments
In NSDictionary+MPCaseInsensitive.m, method transformValuesToString, for NSNumber class, the SDK transforms NSNumber to String with this way:
transformedDictionary[key] = [numberAttribute stringValue];
This can cause issue for value like 0.56:
NSNumber *number1 = [NSNumber numberWithDouble:0.56];
NSNumber *number2 = [NSNumber numberWithDouble:0.55];
NSString *s1 = [number1 stringValue];//0.5600000000000001
NSString *s2 = [number2 stringValue];//0.55
NSString *string1 = [NSNumberFormatter localizedStringFromNumber:number1 numberStyle:NSNumberFormatterDecimalStyle];//0.56
NSString *string2 = [NSNumberFormatter localizedStringFromNumber:number2 numberStyle:NSNumberFormatterDecimalStyle];//0.55
The suggested way is to use NSNumberFormatter with NSNumberFormatterDecimalStyle, do you agree?
The SDK is 8.4.0
See pull request #131
Tracked internally as 66855
Fixed by #131
This is happening again due to code reverse a2280fe