]> Cypherpunks repositories - gostls13.git/commitdiff
math: document more special cases
authorCharles L. Dorian <cldorian@gmail.com>
Thu, 8 Dec 2011 22:07:13 +0000 (17:07 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 8 Dec 2011 22:07:13 +0000 (17:07 -0500)
Acosh, Asinh, Atanh, Ceil, Floor, Trunc, Mod and Remainder affected. These changes add some non-finite arguments and results (and -0.0 results).

R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/5469046

src/pkg/math/acosh.go
src/pkg/math/asinh.go
src/pkg/math/atanh.go
src/pkg/math/floor.go
src/pkg/math/mod.go
src/pkg/math/nextafter.go
src/pkg/math/remainder.go

index 7e8740b89bda2f2455c4466be6a0af5d9d2d5594..8d556377f59a4011668e6860248e2d4b35cb4eea 100644 (file)
@@ -36,6 +36,7 @@ package math
 // Acosh(x) calculates the inverse hyperbolic cosine of x.
 //
 // Special cases are:
+//     Acosh(+Inf) = +Inf
 //     Acosh(x) = NaN if x < 1
 //     Acosh(NaN) = NaN
 func Acosh(x float64) float64 {
index d6979463d65f70b03294ef863ab7b4d1316fef66..f786dd9f8f0996dd4f7339310471f8bab68132d7 100644 (file)
@@ -33,6 +33,7 @@ package math
 // Asinh(x) calculates the inverse hyperbolic sine of x.
 //
 // Special cases are:
+//     Asinh(±0) = ±0
 //     Asinh(±Inf) = ±Inf
 //     Asinh(NaN) = NaN
 func Asinh(x float64) float64 {
index ed38fcac665e57686dcc159bd72e779823b31b07..e150673c7001d0945ccc97d11012575166fbc096 100644 (file)
@@ -39,9 +39,10 @@ package math
 // Atanh(x) calculates the inverse hyperbolic tangent of x.
 //
 // Special cases are:
-//     Atanh(x) = NaN if x < -1 or x > 1
 //     Atanh(1) = +Inf
+//     Atanh(±0) = ±0
 //     Atanh(-1) = -Inf
+//     Atanh(x) = NaN if x < -1 or x > 1
 //     Atanh(NaN) = NaN
 func Atanh(x float64) float64 {
        const NearZero = 1.0 / (1 << 28) // 2**-28
index 8de4d7e2ce68cc1147ef0d088500f59c4f083dce..e5b52c48c1f922934c243b54e2d65f77dfe12e0e 100644 (file)
@@ -7,6 +7,7 @@ package math
 // Floor returns the greatest integer value less than or equal to x.
 //
 // Special cases are:
+//     Floor(±0) = ±0
 //     Floor(±Inf) = ±Inf
 //     Floor(NaN) = NaN
 func Floor(x float64) float64 {
@@ -29,6 +30,7 @@ func Floor(x float64) float64 {
 // Ceil returns the least integer value greater than or equal to x.
 //
 // Special cases are:
+//     Ceil(±0) = ±0
 //     Ceil(±Inf) = ±Inf
 //     Ceil(NaN) = NaN
 func Ceil(x float64) float64 { return -Floor(-x) }
@@ -36,6 +38,7 @@ func Ceil(x float64) float64 { return -Floor(-x) }
 // Trunc returns the integer value of x.
 //
 // Special cases are:
+//     Trunc(±0) = ±0
 //     Trunc(±Inf) = ±Inf
 //     Trunc(NaN) = NaN
 func Trunc(x float64) float64 {
index 6b16abe5d13efa94147469835618a5481684f966..0dd5d0607a5fd2280133da1b7d739333476ef378 100644 (file)
@@ -13,8 +13,11 @@ package math
 // sign agrees with that of x.
 //
 // Special cases are:
-//     if x is not finite, Mod returns NaN
-//     if y is 0 or NaN, Mod returns NaN
+//     Mod(±Inf, y) = NaN
+//     Mod(NaN, y) = NaN
+//     Mod(x, 0) = NaN
+//     Mod(x, ±Inf) = x
+//     Mod(x, NaN) = NaN
 func Mod(x, y float64) float64 {
        // TODO(rsc): Remove manual inlining of IsNaN, IsInf
        // when compiler does it for us.
index 86114340c1eaacc592d794a2ff813ff51f984891..ae1267f752e38029ccffe0d16bed3fc55cc71eea 100644 (file)
@@ -10,6 +10,7 @@ package math
 // Special cases are:
 //     Nextafter(NaN, y) = NaN
 //     Nextafter(x, NaN) = NaN
+//     Nextafter(0, y) = -0, if y < 0
 func Nextafter(x, y float64) (r float64) {
        // TODO(rsc): Remove manual inlining of IsNaN
        // when compiler does it for us
index 7fb8a12f9e61dca0b7a7e81b4b9aa2faecef6941..8d8a7463048f333e169db585e3653303284f7f74 100644 (file)
@@ -29,11 +29,11 @@ package math
 // Remainder returns the IEEE 754 floating-point remainder of x/y.
 //
 // Special cases are:
-//     Remainder(x, NaN) = NaN
+//     Remainder(±Inf, y) = NaN
 //     Remainder(NaN, y) = NaN
-//     Remainder(Inf, y) = NaN
 //     Remainder(x, 0) = NaN
-//     Remainder(x, Inf) = x
+//     Remainder(x, ±Inf) = x
+//     Remainder(x, NaN) = NaN
 func Remainder(x, y float64) float64 {
        const (
                Tiny    = 4.45014771701440276618e-308 // 0x0020000000000000