logo

Comparing NaN in Julia 📂Julia

Comparing NaN in Julia

Description

In Julia, the standard for floating-point numbers follows the IEEE 754 standard. Under this rule, NaN always returns false when compared with all other values. It only returns true when using the != and !== operators.

Code

julia> NaN > 1
false

julia> NaN ≥ 2
false

julia> NaN == 3
false

julia> NaN ≤ 4
false

julia> NaN < 5
false

julia> NaN != 6
true

julia> NaN !== 7
true

When comparing NaN with NaN, only the != operator returns true.

julia> NaN > NaN
false

julia> NaN ≥ NaN
false

julia> NaN == NaN
false

julia> NaN ≤ NaN
false

julia> NaN < NaN
false

julia> NaN != NaN
true

julia> NaN !== NaN
false

Environment

  • OS: Windows11
  • Version: Julia 1.10.0