Closed
Description
#34316 introduced
hypot(x::T, y::T) where {T<:Number} = (z = y/x; abs(x) * sqrt(one(z) + z*z))
If iszero(x)
and iszero(y)
, the above returns NaN instead of zero(T)
.
To trigger this one can use:
using Unitful
hypot(0u"m",0u"m")
One way to fix this would be
hypot(x::T, y::T) where {T<:Number} = !iszero(x) ? (z = y/x; abs(x) * sqrt(one(z) + z*z)) : abs(y)
If the above is ok, I can make a PR.
julia> versioninfo()
Julia Version 1.4.0-rc1.0
Commit b0c33b0cf5 (2020-01-23 17:23 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-7800X CPU @ 3.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
Environment:
JULIA_NUM_THREADS = 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels