Skip to content

Commit 5a3e95d

Browse files
committed
1 parent 24ecff6 commit 5a3e95d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

base/math.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -749,17 +749,17 @@ end
749749
atan(y::Real, x::Real) = atan(promote(float(y),float(x))...)
750750
atan(y::T, x::T) where {T<:AbstractFloat} = Base.no_op_err("atan", T)
751751

752-
max(x::T, y::T) where {T<:AbstractFloat} = ifelse((y > x) | (signbit(y) < signbit(x)),
753-
ifelse(isnan(x), x, y), ifelse(isnan(y), y, x))
752+
_isless(x::T, y::T) where {T<:AbstractFloat} = (x < y) || (signbit(x) > signbit(y))
753+
min(x::T, y::T) where {T<:AbstractFloat} = isnan(x) || ~isnan(y) && _isless(x, y) ? x : y
754+
max(x::T, y::T) where {T<:AbstractFloat} = isnan(x) || ~isnan(y) && _isless(y, x) ? x : y
755+
minmax(x::T, y::T) where {T<:AbstractFloat} = min(x, y), max(x, y)
754756

757+
FastFloat = Union{Float32, Float64}
758+
_isless(x::T, y::T) where {T<:FastFloat} = signbit(x - y)
759+
min(x::T, y::T) where {T<:FastFloat} = ifelse(isnan(x) | ~isnan(y) & _isless(x, y), x, y)
760+
max(x::T, y::T) where {T<:FastFloat} = ifelse(isnan(x) | ~isnan(y) & _isless(y, x), x, y)
755761

756-
min(x::T, y::T) where {T<:AbstractFloat} = ifelse((y < x) | (signbit(y) > signbit(x)),
757-
ifelse(isnan(x), x, y), ifelse(isnan(y), y, x))
758-
759-
minmax(x::T, y::T) where {T<:AbstractFloat} =
760-
ifelse(isnan(x) | isnan(y), ifelse(isnan(x), (x,x), (y,y)),
761-
ifelse((y > x) | (signbit(x) > signbit(y)), (x,y), (y,x)))
762-
762+
_isless(x::Float16, y::Float16) = _isless(widen(x), widen(y))
763763

764764
"""
765765
ldexp(x, n)

0 commit comments

Comments
 (0)