Skip to content
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

fix exp(weirdNaN) #56784

Merged
merged 2 commits into from
Dec 10, 2024
Merged

fix exp(weirdNaN) #56784

merged 2 commits into from
Dec 10, 2024

Conversation

oscardssmith
Copy link
Member

@oscardssmith oscardssmith commented Dec 9, 2024

Fixes #56782
Fix exp(reinterpret(Float64, 0x7ffbb14880000000)) returning non-NaN value. This should have minimal performance impact since it's already in the fallback branch.

Fix `exp(reinterpret(Float64, 0x7ffbb14880000000))` returning non-NaN value.
This should have minimal performance impact since it's already in the fallback branch.
@oscardssmith oscardssmith added maths Mathematical functions bugfix This change fixes an existing bug embarrassing-bugfix Whoops! backport 1.10 Change should be backported to the 1.10 release backport 1.11 Change should be backported to release-1.11 labels Dec 9, 2024
@Seelengrab
Copy link
Contributor

FYI, the "weird" NaN is just a NaN with a different bitpattern than our usual one:

julia> reinterpret(Float64, 0x7ffbb14880000000) |> exp
-9.627794635514914e-309

julia> NaN |> bitstring
"0111111111111000000000000000000000000000000000000000000000000000"

julia> reinterpret(Float64, 0x7ffbb14880000000) |> bitstring
"0111111111111011101100010100100010000000000000000000000000000000"

so a slightly "cleaner" pattern can also serve as a reproducer, as long as the bitpattern is distinct from the usual one:

julia> @check db=false (f=Data.Floats{Float64}())  -> begin
           uint_float = reinterpret(UInt, f)
           event!(uint_float)
           event!(bitstring(uint_float))
           res = exp(f)
           isnan(res) == isnan(f) || res >= 0
       end
Found counterexample
  Context: ##SuppositionAnon#334

  Arguments:
      f::Float64 = NaN

  Events:
    UNLABELED_EVENT_0
        0x7ff0000000000100
    UNLABELED_EVENT_1
        "0111111111110000000000000000000000000000000000000000000100000000"

All of these are proper NaN though, and the fix here also makes this randomized test pass 👍

@KristofferC KristofferC merged commit 19e06d3 into master Dec 10, 2024
12 of 14 checks passed
@KristofferC KristofferC deleted the oscardssmith-patch-1 branch December 10, 2024 14:33
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.11 Change should be backported to release-1.11 bugfix This change fixes an existing bug embarrassing-bugfix Whoops! maths Mathematical functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

exp of some NaNs is negative
3 participants