Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions base/special/exp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ end
N = unsafe_trunc(Int32, N_float)
r = muladd(N_float, LogB(base, Float16), x)
small_part = expb_kernel(base, r)
if !(abs(x) <= SUBNORM_EXP(base, T))
x > MAX_EXP(base, T) && return Inf16
x < MIN_EXP(base, T) && return zero(Float16)
if !(abs(x) <= 25)
x > 16 && return Inf16
x < 25 && return zero(Float16)
end
twopk = reinterpret(T, (N+Int32(127)) << Int32(23))
return Float16(twopk*small_part)
Expand Down
7 changes: 5 additions & 2 deletions test/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,13 @@ end
X = Iterators.flatten((minval:T(.1):maxval,
minval/100:T(.0021):maxval/100,
minval/10000:T(.000021):maxval/10000,
nextfloat(zero(T)) ))
nextfloat(zero(T)),
T(-100):T(1):T(100) ))
for x in X
y, yb = func(x), func(widen(x))
@test abs(y-yb) <= 1.2*eps(T(yb))
if isfinite(eps(T(yb)))
@test abs(y-yb) <= 1.2*eps(T(yb))
end
end
end
@testset "$T $func edge cases" begin
Expand Down