Skip to content

Commit

Permalink
add hypot fallback for 2 Numbers of the same type (#34316)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored and KristofferC committed Jan 13, 2020
1 parent aa35ee2 commit ade4713
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ julia> hypot(3, 4im)
hypot(x::Number, y::Number) = hypot(promote(x, y)...)
hypot(x::Complex, y::Complex) = hypot(abs(x), abs(y))
hypot(x::T, y::T) where {T<:Real} = hypot(float(x), float(y))
hypot(x::T, y::T) where {T<:Number} = (z = y/x; abs(x) * sqrt(one(z) + z*z))
function hypot(x::T, y::T) where T<:AbstractFloat
#Return Inf if either or both imputs is Inf (Compliance with IEEE754)
if isinf(x) || isinf(y)
Expand Down

0 comments on commit ade4713

Please sign in to comment.