Skip to content

Add roundeven{,f,f16,f128} #514

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 2 commits into from
Feb 11, 2025
Merged

Add roundeven{,f,f16,f128} #514

merged 2 commits into from
Feb 11, 2025

Conversation

tgross35
Copy link
Contributor

C23 specifies a new set of roundeven functions that round to the nearest integral, with ties to even. It does not raise any floating point exceptions.

This behavior is similar to two other functions:

  1. rint, which rounds to the nearest integer respecting rounding mode and possibly raising exceptions.
  2. nearbyint, which is identical to rint except it may not raise exceptions.

Technically rint, nearbyint, and roundeven all behave the same in Rust because we assume default floating point environment. The backends are allowed to lower to roundeven, however, so we should provide it in case the fallback is needed.

Add the roundeven family here and convert rint to a function that takes a rounding mode. This currently has no effect.

C23 specifies a new set of `roundeven` functions that round to the
nearest integral, with ties to even. It does not raise any floating
point exceptions.

This behavior is similar to two other functions:

1. `rint`, which rounds to the nearest integer respecting rounding mode
   and possibly raising exceptions.
2. `nearbyint`, which is identical to `rint` except it may not raise
   exceptions.

Technically `rint`, `nearbyint`, and `roundeven` all behave the same in
Rust because we assume default floating point environment. The backends
are allowed to lower to `roundeven`, however, so we should provide it in
case the fallback is needed.

Add the `roundeven` family here and convert `rint` to a function that
takes a rounding mode. This currently has no effect.
@tgross35 tgross35 merged commit c2bf953 into rust-lang:master Feb 11, 2025
35 checks passed
@tgross35 tgross35 deleted the roundeven branch February 11, 2025 06:55
@tgross35 tgross35 mentioned this pull request Apr 18, 2025
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.

1 participant