Skip to content

Commit

Permalink
promote is not needed after JuliaLang#30471
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Fernandez-de-Cossio-Diaz committed May 20, 2019
1 parent e7be164 commit 5f57c66
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ function hypot(x::Number, y::Number)
else
r = ay / ax
end
rr = ax * sqrt(1 + r * r)
rr = ax * sqrt(oneunit(r) + r * r)

if isnan(r)
if isinf(x) || isinf(y)
Expand All @@ -563,14 +563,13 @@ end
Compute the hypotenuse ``\\sqrt{\\sum x_i^2}`` avoiding overflow and underflow.
"""
hypot(x::Number...) = _hypot(promote(x...))
function _hypot(x::NTuple{N,<:Number}) where {N}
function hypot(x::Number...) where {N}
N == 0 && error("invalid hypot() call without arguments")
# speculatively try fast naive approach
s = sum(abs2.(float.(x)))
if isnan(s)
return any(isinf, x) ? oftype(sqrt(s), Inf) : sqrt(s) # IEEE 754
elseif isinf(s) || s _floatmin(s) * (N-1) # FIXME: revisit when #30387 is resolved
elseif isinf(s) || float(s) _floatmin(float(s)) * (N-1)
# if overflow/underflow, try normalization
ma = maximum(abs.(float.(x)))
if iszero(ma) || isinf(ma)
Expand All @@ -587,7 +586,6 @@ _floatmin(x::AbstractFloat) = _floatmin(typeof(x))
_floatmin(::Type{T}) where {T<:AbstractFloat} = nextfloat(zero(T)) / eps(T)
_floatmin(::Type{T}) where {T<:IEEEFloat} = floatmin(T)


atan(y::Real, x::Real) = atan(promote(float(y),float(x))...)
atan(y::T, x::T) where {T<:AbstractFloat} = Base.no_op_err("atan", T)

Expand Down

0 comments on commit 5f57c66

Please sign in to comment.