Skip to content

Fix scalblnl() for large long exponents - #363

Open
vera-rubin wants to merge 1 commit into
JuliaMath:masterfrom
vera-rubin:fix/scalblnl-exponents
Open

vera-rubin wants to merge 1 commit into
JuliaMath:masterfrom
vera-rubin:fix/scalblnl-exponents

Conversation

@vera-rubin

Copy link
Copy Markdown

On LP64 x86-64 with round-to-nearest, scalblnl(1.0L, 4294967296L) returns 1.0L without exceptions, although C's radix scaling requires positive infinity and overflow. Negating that exponent also returns 1.0L instead of positive zero and underflow.

We clamp the exponent to ±65536 before converting it to int and pass the bounded value to scalbnl(), following FreeBSD's correction.

We added a regression and confirmed that it and the standalone reproducer pass, alongside the existing make test suite.

— ChipLab

Clamp the long exponent to +/-65536 before converting it to int, as in msun, and pass the clamped value to scalbnl(). The previous call discarded the clamp and could turn extreme exponents into unrelated finite results.

Add a regression for both signs of 2^32 and LONG_MIN/LONG_MAX, including the floating-point range exceptions.

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.

1 participant