File tree 2 files changed +14
-0
lines changed 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 254
254
end
255
255
@inline function exp_impl_fast (x:: Float64 , base)
256
256
T = Float64
257
+ x >= MAX_EXP (base, T) && return Inf
258
+ x <= - SUBNORM_EXP (base, T) && return 0.0
257
259
N_float = muladd (x, LogBo256INV (base, T), MAGIC_ROUND_CONST (T))
258
260
N = reinterpret (UInt64, N_float) % Int32
259
261
N_float -= MAGIC_ROUND_CONST (T) # N_float now equals round(x*LogBo256INV(base, T))
288
290
289
291
@inline function exp_impl_fast (x:: Float32 , base)
290
292
T = Float32
293
+ x >= MAX_EXP (base, T) && return Inf32
294
+ x <= - SUBNORM_EXP (base, T) && return 0f0
291
295
N_float = round (x* LogBINV (base, T))
292
296
N = unsafe_trunc (Int32, N_float)
293
297
r = muladd (N_float, LogBU (base, T), x)
Original file line number Diff line number Diff line change 249
249
@test (@fastmath " a" * " b" ) == " ab"
250
250
@test (@fastmath " a" ^ 2 ) == " aa"
251
251
end
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