summaryrefslogtreecommitdiff
path: root/src/pkg/math/floor.go
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2012-01-30 15:38:19 +0100
committerOndřej Surý <ondrej@sury.org>2012-01-30 15:38:19 +0100
commit4cecda6c347bd6902b960c6a35a967add7070b0d (patch)
treea462e224ff41ec9f3eb1a0b6e815806f9e8804ad /src/pkg/math/floor.go
parent6c7ca6e4d4e26e4c8cbe0d183966011b3b088a0a (diff)
downloadgolang-4cecda6c347bd6902b960c6a35a967add7070b0d.tar.gz
Imported Upstream version 2012.01.27upstream-weekly/2012.01.27
Diffstat (limited to 'src/pkg/math/floor.go')
-rw-r--r--src/pkg/math/floor.go26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/pkg/math/floor.go b/src/pkg/math/floor.go
index babbf645f..a7090f5e4 100644
--- a/src/pkg/math/floor.go
+++ b/src/pkg/math/floor.go
@@ -7,10 +7,12 @@ package math
// Floor returns the greatest integer value less than or equal to x.
//
// Special cases are:
-// Floor(+Inf) = +Inf
-// Floor(-Inf) = -Inf
+// Floor(±0) = ±0
+// Floor(±Inf) = ±Inf
// Floor(NaN) = NaN
-func Floor(x float64) float64 {
+func Floor(x float64) float64
+
+func floor(x float64) float64 {
// TODO(rsc): Remove manual inlining of IsNaN, IsInf
// when compiler does it for us
if x == 0 || x != x || x > MaxFloat64 || x < -MaxFloat64 { // x == 0 || IsNaN(x) || IsInf(x, 0)
@@ -30,18 +32,24 @@ func Floor(x float64) float64 {
// Ceil returns the least integer value greater than or equal to x.
//
// Special cases are:
-// Ceil(+Inf) = +Inf
-// Ceil(-Inf) = -Inf
+// Ceil(±0) = ±0
+// Ceil(±Inf) = ±Inf
// Ceil(NaN) = NaN
-func Ceil(x float64) float64 { return -Floor(-x) }
+func Ceil(x float64) float64
+
+func ceil(x float64) float64 {
+ return -Floor(-x)
+}
// Trunc returns the integer value of x.
//
// Special cases are:
-// Trunc(+Inf) = +Inf
-// Trunc(-Inf) = -Inf
+// Trunc(±0) = ±0
+// Trunc(±Inf) = ±Inf
// Trunc(NaN) = NaN
-func Trunc(x float64) float64 {
+func Trunc(x float64) float64
+
+func trunc(x float64) float64 {
// TODO(rsc): Remove manual inlining of IsNaN, IsInf
// when compiler does it for us
if x == 0 || x != x || x > MaxFloat64 || x < -MaxFloat64 { // x == 0 || IsNaN(x) || IsInf(x, 0)