-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
| Previous ID | SR-8409 |
| Radar | None |
| Original Reporter | TomasLinhart (JIRA User) |
| Type | Bug |
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Foundation |
| Labels | Bug |
| Assignee | None |
| Priority | Medium |
md5: 87fa6caf176bfbf5ed96bbc10110c73b
is duplicated by:
- SR-11514
Decimal.init(_ value: Double)sometimes yields incorrect value
Issue Description:
Decimal precision is a bit strange for a number 456.789. When you initialize Double with 456.789 it holds the number so it is representable, but if you try to convert it to a decimal with Decimal(456.789) it results in 456.7889999999998976 but if you use Decimal(string: "456.789")! it results in a correct decimal with a value 456.789.
I tried also Objective-C, and it works correctly there:
NSDecimalNumber *number = [[NSDecimalNumber alloc] initWithDouble:456.789];
NSLog(@"Number: %f", number.doubleValue);