Source File
log1p.go
Belonging Package
math
package math
func ( float64) float64
func ( float64) float64 {
const (
= 4.142135623730950488017e-01 // Sqrt(2)-1 = 0x3fda827999fcef34
= -2.928932188134524755992e-01 // Sqrt(2)/2-1 = 0xbfd2bec333018866
= 1.0 / (1 << 29) // 2**-29 = 0x3e20000000000000
= 1.0 / (1 << 54) // 2**-54
= 1 << 53 // 2**53
= 6.93147180369123816490e-01 // 3fe62e42fee00000
= 1.90821492927058770002e-10 // 3dea39ef35793c76
= 6.666666666666735130e-01 // 3FE5555555555593
= 3.999999999940941908e-01 // 3FD999999997FA04
= 2.857142874366239149e-01 // 3FD2492494229359
= 2.222219843214978396e-01 // 3FCC71C51D8E78AF
= 1.818357216161805012e-01 // 3FC7466496CB03DE
= 1.531383769920937332e-01 // 3FC39A09D078C69F
= 1.479819860511658591e-01 // 3FC2F112DF3E5244
)
= 0
=
= 1
}
}
var float64
if != 0 {
var float64
if < { // 1<<53
= 1.0 +
= Float64bits()
if > 0 {
= 1.0 - ( - )
} else {
= - ( - 1.0)
}
/=
} else {
=
= Float64bits()
= int(( >> 52) - 1023)
= 0
}
&= 0x000fffffffffffff
if < 0x0006a09e667f3bcd { // mantissa of Sqrt(2)
= Float64frombits( | 0x3ff0000000000000) // normalize u
} else {
++
= Float64frombits( | 0x3fe0000000000000) // normalize u/2
= (0x0010000000000000 - ) >> 2
}
= - 1.0 // Sqrt(2)/2 < u < Sqrt(2)
}
:= 0.5 * *
var , , float64
if == 0 { // |f| < 2**-20
if == 0 {
if == 0 {
return 0
}
+= float64() *
return float64()* +
}
= * (1.0 - 0.66666666666666666*) // avoid division
if == 0 {
return -
}
return float64()* - (( - (float64()* + )) - )
}
= / (2.0 + )
= *
= * ( + *(+*(+*(+*(+*(+*))))))
if == 0 {
return - ( - *(+))
}
return float64()* - (( - (*(+) + (float64()* + ))) - )
![]() |
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. |