Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
swift-ci opened this issue Mar 20, 2018 · 3 comments

Comments

@swift-ci
Copy link
Contributor

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:

  • SR-2980 NSDecimalNumber's .intValue produces incorrect results for numbers with many numbers after the decimal place

is duplicated by:

  • SR-2980 NSDecimalNumber's .intValue produces incorrect results for numbers with many numbers after the decimal place

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
Copy link

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

@swift-ci create

@spevans
Copy link
Collaborator

spevans commented Nov 20, 2020

Linux fix: #2925

@xwu
Copy link
Collaborator

xwu commented Aug 28, 2021

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

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants