summaryrefslogtreecommitdiff
path: root/src/pkg/math/log1p.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/math/log1p.go')
-rw-r--r--src/pkg/math/log1p.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/pkg/math/log1p.go b/src/pkg/math/log1p.go
index c25d73b66..12b98684c 100644
--- a/src/pkg/math/log1p.go
+++ b/src/pkg/math/log1p.go
@@ -44,7 +44,7 @@ package math
// 2 4 6 8 10 12 14
// R(z) ~ Lp1*s +Lp2*s +Lp3*s +Lp4*s +Lp5*s +Lp6*s +Lp7*s
// (the values of Lp1 to Lp7 are listed in the program)
-// a-0.2929nd
+// and
// | 2 14 | -58.45
// | Lp1*s +...+Lp7*s - R(z) | <= 2
// | |
@@ -88,10 +88,13 @@ package math
//
// Special cases are:
// Log1p(+Inf) = +Inf
+// Log1p(±0) = ±0
// Log1p(-1) = -Inf
// Log1p(x < -1) = NaN
// Log1p(NaN) = NaN
-func Log1p(x float64) float64 {
+func Log1p(x float64) float64
+
+func log1p(x float64) float64 {
const (
Sqrt2M1 = 4.142135623730950488017e-01 // Sqrt(2)-1 = 0x3fda827999fcef34
Sqrt2HalfM1 = -2.928932188134524755992e-01 // Sqrt(2)/2-1 = 0xbfd2bec333018866
@@ -110,14 +113,12 @@ func Log1p(x float64) float64 {
)
// special cases
- // TODO(rsc): Remove manual inlining of IsNaN, IsInf
- // when compiler does it for us
switch {
- case x < -1 || x != x: // x < -1 || IsNaN(x): // includes -Inf
+ case x < -1 || IsNaN(x): // includes -Inf
return NaN()
case x == -1:
return Inf(-1)
- case x > MaxFloat64: // IsInf(x, 1):
+ case IsInf(x, 1):
return Inf(1)
}