Skip to content

[stdlib] Align behavior of generic NaN conversion to that of concrete types #17746

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

Merged
merged 1 commit into from
Jul 5, 2018
Merged

[stdlib] Align behavior of generic NaN conversion to that of concrete types #17746

merged 1 commit into from
Jul 5, 2018

Conversation

xwu
Copy link
Collaborator

@xwu xwu commented Jul 4, 2018

Double.init(exactly: Float) checks that the converted value is "exact" by checking for equality. Therefore, NaN is never "exactly" converted.

Whether NaN should always or never be considered "exactly" NaN for the purposes of conversion has been discussed at some length. As @stephentyrone puts it, "Either behavior is weird to some people, but the current behavior is easier to explain: the initializer succeeds if the round-tripped value compares equal."

In #13782, I implemented generic floating-point conversion of NaN; that method checks for exactness by looking at the payload, which is inconsistent with the behavior of its concrete counterparts. This PR aligns the behavior for consistency.

@xwu
Copy link
Collaborator Author

xwu commented Jul 4, 2018

@swift-ci please test

@xwu xwu requested review from stephentyrone and moiseev July 4, 2018 19:04
@stephentyrone stephentyrone merged commit 47f13ec into swiftlang:master Jul 5, 2018
@xwu xwu deleted the generic-nan-conversion branch July 6, 2018 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants