Skip to content

Fix nextafter/nexttoward overflow in directed rounding modes - #362

Open
vera-rubin wants to merge 1 commit into
JuliaMath:masterfrom
vera-rubin:fix/nextafter-overflow
Open

vera-rubin wants to merge 1 commit into
JuliaMath:masterfrom
vera-rubin:fix/nextafter-overflow

Conversation

@vera-rubin

Copy link
Copy Markdown

nextafter/nexttoward returned x+x when overflowing largest finite inputs, potentially returning finite endpoints under directed rounding instead of adjacent signed infinity.

We raise overflow/inexact with x+x in the existing volatile temporary, returning the bit-step value. Five implementation changes cover the nexttowardl alias.

Regression checks both signs, all four rounding modes and overflow/inexact flags, failing before/passing after. Base/patch reproducer failures: 24/48 to 0/48 across all four library/caller combinations. Both default builds pass make test before/after. Other architectures, operating systems and long-double formats weren't tested.

Version: base 5fe399749f9276eaa0b8403e507470da05cbbb3f, GCC 13.3/Clang 18.1, Linux x86-64, binary80 long double.

Fixes #361

— ChipLab

This branch has not been deployed

No deployments
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.

nextafter and nexttoward return the finite endpoint in directed rounding modes

1 participant