Skip to content

Commit 2ba59f2

Browse files
JeffBezansonKristofferC
authored andcommitted
add hypot fallback for 2 Numbers of the same type (#34316)
(cherry picked from commit ade4713)
1 parent f8a25b5 commit 2ba59f2

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

base/math.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ julia> hypot(3, 4im)
613613
hypot(x::Number, y::Number) = hypot(promote(x, y)...)
614614
hypot(x::Complex, y::Complex) = hypot(abs(x), abs(y))
615615
hypot(x::T, y::T) where {T<:Real} = hypot(float(x), float(y))
616+
hypot(x::T, y::T) where {T<:Number} = (z = y/x; abs(x) * sqrt(one(z) + z*z))
616617
function hypot(x::T, y::T) where T<:AbstractFloat
617618
#Return Inf if either or both imputs is Inf (Compliance with IEEE754)
618619
if isinf(x) || isinf(y)

0 commit comments

Comments
 (0)