NSDecimalNumber issue with doubleValue method
Originator: | dkulemalin | ||
Number: | rdar://42374293 | Date Originated: | 07/19/2018 |
Status: | OPEN | Resolved: | NO |
Product: | iOS | Product Version: | 11.0 |
Classification: | Other | Reproducible: | 100% |
Area: Foundation Summary: NSDecimalNumber doubleValue method returns not accurate value. Steps to Reproduce: double a = 7928.46; NSDecimalNumber *number = (NSDecimalNumber *)[NSDecimalNumber numberWithDouble:a]; double b = [number doubleValue]; BOOL equal = (a - b) == 0; double c = [[number stringValue] doubleValue]; BOOL equal2 = a - c == 0; Expected Results: equal == YES equal2 == YES Actual Results: equal == NO (because b == 7928.4600000000009) equal2 == YES Is it possible to improve this method in order to return accurate values when value itself is accurate? Version/Build: xCode 9.4.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!