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-2980] NSDecimalNumber's .intValue produces incorrect results for numbers with many numbers after the decimal place #4315
Comments
Comment by Fabian Emmes (JIRA) I also noticed this bug, using Swift 3.0.1: Apple Swift version 3.0.1 (swiftlang-800.0.58.6 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9 And indeed it looks as if it depends on the number of decimal places: 14> NSDecimalNumber(string: "250.229953885078403").int64Value
$R4: Int64 = 250
15> NSDecimalNumber(string: "250.22995388507840317").int64Value
$R5: Int64 = 65
16> NSDecimalNumber(string: "250.2299538850784031744").int64Value
$R6: Int64 = 0 |
Comment by Andrew Hoos (JIRA) This seems to be resolved in top of tree master. |
The problem still exists in Swift 4.2 (Xcode 10):
Another example:
|
The wrong results can still be reproduced with Apple Swift version 4.2 (swiftlang-1000.11.37.1 clang-1000.11.45.1) that comes with Xcode 10, therefore I have reopened the issue. |
Got this problem with current Swift 5.1.3 (Xcode 11.3.1) |
To reproduce on Swift 5.1.3:
|
Linux fix: #2925 |
To reproduce with Swift 5.7 on macOS:
|
Reproducable with Swift 5.9 on macOS:
|
|
Environment
XCode Version: Version 8.0 (8A218a)
Additional Detail from JIRA
md5: edd4e608242098a65d37a036b1051abb
duplicates:
.intValue
reporting 0 on numbers with many decimalsis duplicated by:
.intValue
reporting 0 on numbers with many decimalsIssue Description:
For NSDecimalNumbers with a lot of numbers after the decimal point, .intValue is always zero. Experimentally, it looks like the crossover point where .intValue becomes incorrect is around 19 places after the decimal point (but I haven't tested this extensively).
.int64Value has the same behavior. .int32Value, .int16Value and .int8Value do not.
Test Case:
The text was updated successfully, but these errors were encountered: