diff options
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) |