@@ -20,13 +20,23 @@ import Base: log, exp, sin, cos, tan, sinh, cosh, tanh, asin,
20
20
max, min, minmax, ^ , exp2, muladd, rem,
21
21
exp10, expm1, log1p
22
22
23
- using Base: sign_mask, exponent_mask, exponent_one, exponent_bias,
24
- exponent_half, exponent_max, exponent_raw_max, fpinttype,
25
- significand_mask, significand_bits, exponent_bits
23
+ using Base: sign_mask, exponent_mask, exponent_one,
24
+ exponent_half, fpinttype, significand_mask
26
25
27
26
using Core. Intrinsics: sqrt_llvm
28
27
29
- const IEEEFloat = Union{Float16,Float32,Float64}
28
+ const IEEEFloat = Union{Float16, Float32, Float64}
29
+
30
+ for T in (Float16, Float32, Float64)
31
+ @eval significand_bits (:: Type{$T} ) = $ (trailing_ones (significand_mask (T)))
32
+ @eval exponent_bits (:: Type{$T} ) = $ (sizeof (T)* 8 - significand_bits (T) - 1 )
33
+ @eval exponent_bias (:: Type{$T} ) = $ (Int (exponent_one (T) >> significand_bits (T)))
34
+ # maximum float exponent
35
+ @eval exponent_max (:: Type{$T} ) = $ (Int (exponent_mask (T) >> significand_bits (T)) - exponent_bias (T))
36
+ # maximum float exponent without bias
37
+ @eval exponent_raw_max (:: Type{$T} ) = $ (Int (exponent_mask (T) >> significand_bits (T)))
38
+ end
39
+
30
40
# non-type specific math functions
31
41
32
42
"""
@@ -229,8 +239,6 @@ for f in (:cbrt, :sinh, :cosh, :tanh, :atan, :asinh, :exp2, :expm1)
229
239
($ f)(x:: Real ) = ($ f)(float (x))
230
240
end
231
241
end
232
- # pure julia exp function
233
- include (" special/exp.jl" )
234
242
exp (x:: Real ) = exp (float (x))
235
243
236
244
# fallback definitions to prevent infinite loop from $f(x::Real) def above
690
698
@inline ^ (x:: Float64 , y:: Integer ) = x ^ Float64 (y)
691
699
@inline ^ (x:: Float32 , y:: Integer ) = x ^ Float32 (y)
692
700
@inline ^ (x:: Float16 , y:: Integer ) = Float16 (Float32 (x) ^ Float32 (y))
693
- ^ {p}(x:: Float16 , :: Type{Val{p}} ) = Float16 (Float32 (x)^ Val{p})
701
+ @inline ^ {p}(x:: Float16 , :: Type{Val{p}} ) = Float16 (Float32 (x) ^ Val{p})
694
702
695
703
function angle_restrict_symm (theta)
696
704
const P1 = 4 * 7.8539812564849853515625e-01
950
958
cbrt (a:: Float16 ) = Float16 (cbrt (Float32 (a)))
951
959
952
960
# More special functions
961
+ include (" special/exp.jl" )
953
962
include (" special/trig.jl" )
954
963
include (" special/gamma.jl" )
955
964
0 commit comments