You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Xcode Version 12.3 (12C33)/macOS Big Sur 11.2 Beta (20D5029f)
Additional Detail from JIRA
Votes
1
Component/s
Foundation
Labels
Bug
Assignee
None
Priority
Medium
md5: c2eacc694dc7f45ed8434ce579601972
Issue Description:
pow(_ x: Decimal, _ y: Int) is a thin wrapper around NSDecimalPower. NSDecimalPower`s power argument is an NSUInteger but Swift exposes it as an Int, which gets casted as a UInt (presumably so the code can be translated in a straightforwards way from Foundation.framework). This means that the "reasonable-looking" pow(10 as Decimal, -2) is really "pow(10 as Decimal, 18446744073709551614 as UInt)". Internally this causes an overflow which is then exposed as a NaN because it seems like Decimal doesn't actually have a way of representing infinity. In the absence of the latter being fixed, it would be nice if the function at least took a UInt or had behavior that worked for negative integers.
The text was updated successfully, but these errors were encountered:
Environment
Xcode Version 12.3 (12C33)/macOS Big Sur 11.2 Beta (20D5029f)
Additional Detail from JIRA
md5: c2eacc694dc7f45ed8434ce579601972
Issue Description:
pow(_ x: Decimal, _ y: Int)
is a thin wrapper aroundNSDecimalPower
.NSDecimalPower
`spower
argument is anNSUInteger
but Swift exposes it as anInt
, which gets casted as aUInt
(presumably so the code can be translated in a straightforwards way from Foundation.framework). This means that the "reasonable-looking"pow(10 as Decimal, -2)
is really "pow(10 as Decimal, 18446744073709551614 as UInt)
". Internally this causes an overflow which is then exposed as a NaN because it seems likeDecimal
doesn't actually have a way of representing infinity. In the absence of the latter being fixed, it would be nice if the function at least took aUInt
or had behavior that worked for negative integers.The text was updated successfully, but these errors were encountered: