diff options
| author | Ondřej Surý <ondrej@sury.org> | 2012-02-29 11:23:13 +0100 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2012-02-29 11:23:13 +0100 |
| commit | b6d7097a0d6072199f2cd74d67404890697cf78a (patch) | |
| tree | a2193c528a79fd5606507568859ee5067c6b86e4 /src/pkg/math/logb.go | |
| parent | 4cecda6c347bd6902b960c6a35a967add7070b0d (diff) | |
| download | golang-b6d7097a0d6072199f2cd74d67404890697cf78a.tar.gz | |
Imported Upstream version 2012.02.22upstream-weekly/2012.02.22
Diffstat (limited to 'src/pkg/math/logb.go')
| -rw-r--r-- | src/pkg/math/logb.go | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/pkg/math/logb.go b/src/pkg/math/logb.go index 072281ddf..d32f9f100 100644 --- a/src/pkg/math/logb.go +++ b/src/pkg/math/logb.go @@ -11,15 +11,13 @@ package math // Logb(0) = -Inf // Logb(NaN) = NaN func Logb(x float64) float64 { - // TODO(rsc): Remove manual inlining of IsNaN, IsInf - // when compiler does it for us // special cases switch { case x == 0: return Inf(-1) - case x < -MaxFloat64 || x > MaxFloat64: // IsInf(x, 0): + case IsInf(x, 0): return Inf(1) - case x != x: // IsNaN(x): + case IsNaN(x): return x } return float64(ilogb(x)) @@ -32,15 +30,13 @@ func Logb(x float64) float64 { // Ilogb(0) = MinInt32 // Ilogb(NaN) = MaxInt32 func Ilogb(x float64) int { - // TODO(rsc): Remove manual inlining of IsNaN, IsInf - // when compiler does it for us // special cases switch { case x == 0: return MinInt32 - case x != x: // IsNaN(x): + case IsNaN(x): return MaxInt32 - case x < -MaxFloat64 || x > MaxFloat64: // IsInf(x, 0): + case IsInf(x, 0): return MaxInt32 } return ilogb(x) |
