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 227
227
end
228
228
@inline function exp_impl_fast (x:: Float64 , base)
229
229
T = Float64
230
+ x >= MAX_EXP (base, T) && return Inf
231
+ x <= - SUBNORM_EXP (base, T) && return 0.0
230
232
N_float = muladd (x, LogBo256INV (base, T), MAGIC_ROUND_CONST (T))
231
233
N = reinterpret (UInt64, N_float) % Int32
232
234
N_float -= MAGIC_ROUND_CONST (T) # N_float now equals round(x*LogBo256INV(base, T))
261
263
262
264
@inline function exp_impl_fast (x:: Float32 , base)
263
265
T = Float32
266
+ x >= MAX_EXP (base, T) && return Inf32
267
+ x <= - SUBNORM_EXP (base, T) && return 0f0
264
268
N_float = round (x* LogBINV (base, T))
265
269
N = unsafe_trunc (Int32, N_float)
266
270
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