Closed DanielVandH closed 1 year ago
For which types T
is T(NaN)
supposed to work? I'd guess T <: AbstractFloat
is ok, but we'd need to check to be sure.
I believe only AbstractFloat
s, based on this definition of isnan
from Base
isnan(x::AbstractFloat) = (x != x)::Bool
isnan(x::Number) = false
checking only AbstractFloat
s.
sqrt(x::T) where {T<:AbstractFloat} = x < 0.0 ? T(NaN) : Base.sqrt(x)
sqrt(x::Real) = sqrt(float(x))
seems reasonable then
Base: 97.02% // Head: 97.05% // Increases project coverage by +0.02%
:tada:
Coverage data is based on head (
2727977
) compared to base (65a5928
). Patch coverage: 100.00% of modified lines in pull request are covered.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Ah, I'm guessing the integer issues are a reason for not converting it initially? Unless perhaps
sqrt(x::T) where {T<:Number}
and
sqrt(x::Integer)
ought to be separated? The point being for floats to at least be able to avoid e.g.
This doesn't happen for the other functions like
log
since the methods forFloats
and others are separated intowhich could also be done here, though you still get
Union
s as above.