This is an error
julia> sign(π)
ERROR: InexactError: Bool(-1)
Stacktrace:
[1] Bool
@ ./float.jl:158 [inlined]
[2] convert
@ ./number.jl:7 [inlined]
[3] oftype(x::Bool, y::Int64)
@ Base ./essentials.jl:396
[4] sign(x::Irrational{:π})
@ Base ./number.jl:162
[5] top-level scope
@ REPL[1]:1
but this is not
julia> sign(-π)
-1.0
because here (in base/number.jl)
sign(x::Real) = ifelse(x < zero(x), oftype(one(x),-1), ifelse(x > zero(x), one(x), typeof(one(x))(x)))
Is this because one(π) == true
and it’s trying to cast -1
to a Bool
?