Source File
expm1.go
Belonging Package
math
package math
func ( float64) float64
func ( float64) float64 {
const (
= 7.09782712893383973096e+02 // 0x40862E42FEFA39EF
= 3.88162421113569373274e+01 // 0x4043687a9f1af2b1
= 1.03972077083991796413e+00 // 0x3ff0a2b23f3bab73
= 3.46573590279972654709e-01 // 0x3fd62e42fefa39ef
= 6.93147180369123816490e-01 // 0x3fe62e42fee00000
= 1.90821492927058770002e-10 // 0x3dea39ef35793c76
= 1.44269504088896338700e+00 // 0x3ff71547652b82fe
= -3.33333333333331316428e-02 // 0xBFA11111111110F4
= 1.58730158725481460165e-03 // 0x3F5A01A019FE5585
= -7.93650757867487942473e-05 // 0xBF14CE199EAADBB7
= 4.00821782732936239552e-06 // 0x3ED0CFCA86E65239
= -2.01099218183624371326e-07 // 0xBE8AFDB76E09C32D
)
if >= { // if |x| >= 56 * ln2
if {
return -1 // x < -56*ln2, return -1
}
if >= { // if |x| >= 709.78...
return Inf(1)
}
}
var float64
var int
if > { // if |x| > 0.5 * ln2
var , float64
if < { // and |x| < 1.5 * ln2
if ! {
= -
=
= 1
} else {
= +
= -
= -1
}
} else {
if ! {
= int(* + 0.5)
} else {
= int(* - 0.5)
}
:= float64()
= - * // t * Ln2Hi is exact here
= *
}
= -
= ( - ) -
} else if < { // when |x| < 2**-54, return x
return
} else {
= 0
}
:= 0.5 *
:= *
:= 1 + *(+*(+*(+*(+*))))
:= 3 - *
:= * (( - ) / (6.0 - *))
if == 0 {
return - (* - ) // c is 0
}
= (*(-) - )
-=
switch {
case == -1:
return 0.5*(-) - 0.5
case == 1:
if < -0.25 {
return -2 * ( - ( + 0.5))
}
return 1 + 2*(-)
case <= -2 || > 56: // suffice to return exp(x)-1
:= 1 - ( - )
= Float64frombits(Float64bits() + uint64()<<52) // add k to y's exponent
return - 1
}
if < 20 {
:= Float64frombits(0x3ff0000000000000 - (0x20000000000000 >> uint())) // t=1-2**-k
:= - ( - )
= Float64frombits(Float64bits() + uint64()<<52) // add k to y's exponent
return
}
= Float64frombits(uint64(0x3ff-) << 52) // 2**-k
:= - ( + )
++
= Float64frombits(Float64bits() + uint64()<<52) // add k to y's exponent
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |