Skip to content

Risc-V and perhaps x86, issue with NaN #56672

Open
@stensmo

Description

While testing

julia/test/numbers.jl

Lines 2917 to 2930 in 94f542d

@testset "random NaNs" begin
nans = AbstractFloat[NaN16, NaN32, NaN64]
F = [Float16, Float32, Float64]
U = [UInt16, UInt32, UInt64]
sig = [11, 24, 53]
for i = 1:length(F), j = 1:length(F)
for _ = 1:100
nan = reinterpret(F[i], rand(U[i]) | reinterpret(U[i], nans[i]))
z = sig[i] - sig[j]
nan′ = i <= j ? nan : reinterpret(F[i], reinterpret(U[i], nan) >> z << z)
@test convert(F[i], convert(F[j], nan)) === nan′
end
end
end
some tests related to NaN are failing. The issue relates to negative NaN and positive Nan. Why is it so important that the sign is correct? In that case:

On X86

julia> 0.0*Inf64===-NaN64
true

On Risc-V

julia> 0.0*Inf64===NaN64
true

Why does X86 provide the negative Nan? If you only look at the type and use isnan, everything works as expected on all platforms. In that case, the tests can be modified.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    mathsMathematical functionssystem:riscvSupport for Risc-V cpus

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions