-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SR-6960] Floating-point nextUp and nextDown are unnecessarily slow for concrete types #49508
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
Comments
So is it OK for a future implementation to differ from the current implementation by silencing signaling NaNs? I assume it is, but perhaps it's still worth to clarify? Ie, let's rename the example implementation in the description to nextUp2, then:
This goes against (a perhaps too strict interpretation of) the documentation of .nextUp since x.nextUp2 is not x itself: |
No, not too strict an interpretation. The IEEE standard specifically will point out where it is OK and not OK to silence NaN and we will need to check. |
nextUp should silence signaling nans (and canonicalize results in formats that have non-canonical values), so this also fixes a bug. More broadly, any operation that isn’t explicitly defined to preserve sNaN in 754 is expected to signal and return qNaN. |
The documentation should really be read as “is x itself (canonicalized and silenced as appropriate).” This is a detail that I would say is out of scope for the documentation of an individual function, though perhaps we can come up with some standard terminology. |
Faster versions of nextUp, ulp, and binade are included for Float and Double in PR #15021. |
Thanks Xiaodi! |
Convenience link: #15021 |
Additional Detail from JIRA
md5: cc10aebb523597a05ab15d027507566e
Issue Description:
As discussed on the Swift forums, implementations of
nextUp
andnextDown
are unnecessarily slow for concrete types.For example, a specialized version of
Float.nextUp
that would be significantly faster is:We should have efficient, specialized implementations such as this. Similar issues may apply to
binade
andulp
.The text was updated successfully, but these errors were encountered: