Skip to content

Conversation

adienes
Copy link
Member

@adienes adienes commented Sep 26, 2025

fixes #59661

@adienes adienes added maths Mathematical functions bugfix This change fixes an existing bug labels Sep 26, 2025
@adienes adienes added backport 1.10 Change should be backported to the 1.10 release backport 1.12 Change should be backported to release-1.12 labels Sep 26, 2025
@adienes
Copy link
Member Author

adienes commented Sep 26, 2025

I think the docs could stand an update, as applying a function -n times doesn't make much sense (although ofc most people will likely understand what it's intending to say)

instead of

nextfloat(x::AbstractFloat, n::Integer)
The result of n iterative applications of nextfloat to x if n >= 0, or -n applications of prevfloat if n < 0.

it should probably be something more like

The result of n iterative applications of nextfloat to x if n >= 0, or if n < 0, return a value p such that prevfloat(p, n) == x

but I don't want to change the docs in this PR as that would likely invite stricter scrutiny

@nsajko
Copy link
Member

nsajko commented Sep 27, 2025

This change could break prevfloat for a package which implements nextfloat and expects prevfloat to have a generic fall back implemented using nextfloat. So I think this may be a "minor change"?

@nsajko
Copy link
Member

nsajko commented Sep 27, 2025

I guess you may want to use the new ispositive and isnegative, instead of <.

@adienes
Copy link
Member Author

adienes commented Sep 27, 2025

This change could break prevfloat for a package which implements nextfloat and expects prevfloat to have a generic fall back implemented using nextfloat

those packages were already broken as the existing fallback is incorrect

@KristofferC KristofferC mentioned this pull request Sep 30, 2025
31 tasks
@vtjnash vtjnash requested a review from oscardssmith October 3, 2025 20:05
Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adienes adienes merged commit 3b1fa7c into JuliaLang:master Oct 5, 2025
5 of 7 checks passed
@adienes adienes deleted the prevfloat_unsigned branch October 5, 2025 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.10 Change should be backported to the 1.10 release backport 1.12 Change should be backported to release-1.12 bugfix This change fixes an existing bug maths Mathematical functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Underflow in prevfloat with Unsigned iteration count
4 participants