Skip to content

Commit 229c124

Browse files
committed
1 parent 26dc4c0 commit 229c124

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
@@ -732,17 +732,17 @@ end
732732
atan(y::Real, x::Real) = atan(promote(float(y),float(x))...)
733733
atan(y::T, x::T) where {T<:AbstractFloat} = Base.no_op_err("atan", T)
734734

735-
max(x::T, y::T) where {T<:AbstractFloat} = ifelse((y > x) | (signbit(y) < signbit(x)),
736-
ifelse(isnan(x), x, y), ifelse(isnan(y), y, x))
735+
_isless(x::T, y::T) where {T<:AbstractFloat} = (x < y) || (signbit(x) > signbit(y))
736+
min(x::T, y::T) where {T<:AbstractFloat} = isnan(x) || ~isnan(y) && _isless(x, y) ? x : y
737+
max(x::T, y::T) where {T<:AbstractFloat} = isnan(x) || ~isnan(y) && _isless(y, x) ? x : y
738+
minmax(x::T, y::T) where {T<:AbstractFloat} = min(x, y), max(x, y)
737739

740+
FastFloat = Union{Float32, Float64}
741+
_isless(x::T, y::T) where {T<:FastFloat} = signbit(x - y)
742+
min(x::T, y::T) where {T<:FastFloat} = ifelse(isnan(x) | ~isnan(y) & _isless(x, y), x, y)
743+
max(x::T, y::T) where {T<:FastFloat} = ifelse(isnan(x) | ~isnan(y) & _isless(y, x), x, y)
738744

739-
min(x::T, y::T) where {T<:AbstractFloat} = ifelse((y < x) | (signbit(y) > signbit(x)),
740-
ifelse(isnan(x), x, y), ifelse(isnan(y), y, x))
741-
742-
minmax(x::T, y::T) where {T<:AbstractFloat} =
743-
ifelse(isnan(x) | isnan(y), ifelse(isnan(x), (x,x), (y,y)),
744-
ifelse((y > x) | (signbit(x) > signbit(y)), (x,y), (y,x)))
745-
745+
_isless(x::Float16, y::Float16) = _isless(widen(x), widen(y))
746746

747747
"""
748748
ldexp(x, n)

0 commit comments

Comments
 (0)