File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 227227end
228228@inline function exp_impl_fast (x:: Float64 , base)
229229 T = Float64
230+ x >= MAX_EXP (base, T) && return Inf
231+ x <= - SUBNORM_EXP (base, T) && return 0.0
230232 N_float = muladd (x, LogBo256INV (base, T), MAGIC_ROUND_CONST (T))
231233 N = reinterpret (UInt64, N_float) % Int32
232234 N_float -= MAGIC_ROUND_CONST (T) # N_float now equals round(x*LogBo256INV(base, T))
261263
262264@inline function exp_impl_fast (x:: Float32 , base)
263265 T = Float32
266+ x >= MAX_EXP (base, T) && return Inf32
267+ x <= - SUBNORM_EXP (base, T) && return 0f0
264268 N_float = round (x* LogBINV (base, T))
265269 N = unsafe_trunc (Int32, N_float)
266270 r = muladd (N_float, LogBU (base, T), x)
Original file line number Diff line number Diff line change 249249 @test (@fastmath " a" * " b" ) == " ab"
250250 @test (@fastmath " a" ^ 2 ) == " aa"
251251end
252+
253+
254+ @testset " exp overflow and underflow" begin
255+ for T in (Float32,Float64)
256+ for func in (@fastmath exp2,exp,exp10)
257+ @test func (T (2000 )) == T (Inf )
258+ @test func (T (- 2000 )) == T (0 )
259+ end
260+ end
261+ end
You can’t perform that action at this time.
0 commit comments