-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix NSDecimalPower(_:_:_:_:)
behavior
#4799
base: main
Are you sure you want to change the base?
Conversation
@swift-ci test |
Either the tests or the implementation need to be updated as this test case fails on CI. |
- rename power to absPower - compare p to 0 and 1, instead of absPower (comparing absPower to 1 results in invalid results) - extract tests for negative power method to external test method - typecast test results to NSDecimalNumber in tests, since by default they were Int
@swift-ci test |
@swift-ci test windows |
@compnerd I'm not seeing this macOS CI failure on PRs that you merged recently. Would you agree that it's sporadic and unrelated to this change and that it can be safely merged? |
@MaxDesiatov I think it would be good to understand whats going on though, the macOS build has been somewhat fragile. |
@swift-ci please test macOS platform |
@swift-ci test macos |
1 similar comment
@swift-ci test macos |
@swift-ci test |
This still seems relevant, and we just moved this stuff around too. @iCharlesHu can you take a look please? |
It seems like it's still relevant, but now this issue appears in this repo and the swift-foundation. Should I close this PR and apply fix directly to swift-foundation or both PRs should be updated to the latest changes? |
The idea here is that swift-foundation contains the canonical implementation (shared with Darwin). swift-corelibs-foundation exposes the free-standing function for Linux. |
NSDecimalPower
acceptsInt
aspower
parameter, but internally it callspower(_:roundingMode:)
method, that accepts onlyUInt
as power value. That results in overflow error for every call ofNSDecimalPower
with negativepower
parameter.This PR fixes that behavior by modifying
power
method by makingp
an Int and adds additional code for handling negativep
.This PR solves #3237