-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[SR-6671] Fix Decimal
implementation of FloatingPoint
constants
#3067
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
Conversation
@swift-ci test |
0aa7855
to
d79cb1c
Compare
@swift-ci test |
@swift-ci test macOS |
d79cb1c
to
3f3dab9
Compare
@swift-ci test |
3f3dab9
to
87850da
Compare
@swift-ci test |
(Just back from vacation, sorry for delay in reading this) I'm worried about changing the value of |
@stephentyrone Yeah, I as well. On the other hand, the value of the property is currently documented in a way that emphasizes its "magnitudeness" and there may be current code subtly broken relying on that. I think this should be deprecated regardless with a good error message, but it's not clear to me which value of the property is best in its deprecated state. |
Default assumption should be that already-compiled code is happy with the existing behavior (wrong though it may be), and we shouldn't break them. New code will get a deprecation warning, so we can catch them there. @spevans, how do you want to handle this? (Note that |
@stephentyrone See #3071. |
This PR is a reprise of #1386, which has long ago gone stale. There are several issues with
Decimal
implementations ofFloatingPoint
constants:First, as reported in SR-6671, the
leastNormalMagnitude
and theleastNonzeroMagnitude
actually aren't. This is corrected in both the overlay and in swift-corelibs, with amendments to the corresponding tests.Second, as pointed out by @stephentyrone in #1386, the implementation of
leastFiniteMagnitude
is incorrect. (It is also not a constant required byFloatingPoint
, but with API stability it's too late now to remove fromDecimal
's API. It is left to the code owners as a separate matter whether they wish to deprecate this API.) Apple's documentation of the API states that it is "the decimal that contains the smallest possible non-infinite magnitude for the underlying representation." Magnitude is never negative, and the correct value here is zero. In this PR we make this API an explicit synonym for.zero
. This is corrected in both the overlay and in swift-corelibs, with amendments to the corresponding tests.