swiftlang / swift-corelibs-foundation

The Foundation Project, providing core utilities, internationalization, and OS independence
swift.org
Apache License 2.0
5.27k stars 1.13k forks source link

[SR-7236] NSDecimalNumber `.intValue` reporting 0 on numbers with many decimals #4037

Open swift-ci opened 6 years ago

swift-ci commented 6 years ago
Previous ID SR-7236
Radar rdar://problem/38665975
Original Reporter stjernegard (JIRA User)
Type Bug

Attachment: Download

Environment Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2) on MacOS 10.13.3 (17D102)
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Foundation | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 7432d38cca097fb412157a77bfeb51fe

duplicates:

is duplicated by:

Issue Description:

This is easily shown by running `NSDecimalNumber(value: 10).dividing(by: 3).intValue`. It will return 0, but the expected value is 3.

`NSDecimalNumber(value: 10).dividing(by: 3).doubleValue` correctly returns `3.3333333333333335`.

Running `NSDecimalNumber(value: 10).dividing(by: 3)` in the Swift CLI will show an assertion failure which I believe to be related. - Full text attached.

belkadan commented 6 years ago

The assertion is coming from LLDB, so I think that's unrelated.

@swift-ci create

spevans commented 3 years ago

Linux fix: https://github.com/apple/swift-corelibs-foundation/pull/2925

xwu commented 3 years ago

This remains a problem on macOS as of Swift 5.5 on Monterey, but that's a problem with the closed-source Foundation.