aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/math/bits.go
diff options
context:
space:
mode:
authorCharles L. Dorian <cldorian@gmail.com>2010-02-18 23:33:15 -0800
committerRuss Cox <rsc@golang.org>2010-02-18 23:33:15 -0800
commitc3fa32c7478754021558e99b39e634dcda34ba48 (patch)
tree44e37226ae6ae9c2e388e717e4e2aea3f8dbac3d /src/pkg/math/bits.go
parent4af0a58ea90f84d31ff87a0d3e140b71419a22fa (diff)
downloadgo-c3fa32c7478754021558e99b39e634dcda34ba48.tar.xz
math: add Cbrt and Sincos; x87 versions of Sincos, Frexp, Ldexp
Added special condition and benchmarks for Cbrt, Sincos. Took Frexp and Ldexp out of bits.go. R=rsc CC=golang-dev https://golang.org/cl/206084
Diffstat (limited to 'src/pkg/math/bits.go')
-rw-r--r--src/pkg/math/bits.go48
1 files changed, 0 insertions, 48 deletions
diff --git a/src/pkg/math/bits.go b/src/pkg/math/bits.go
index ccbcf062f8..d36cd18d76 100644
--- a/src/pkg/math/bits.go
+++ b/src/pkg/math/bits.go
@@ -47,51 +47,3 @@ func IsInf(f float64, sign int) bool {
// return sign >= 0 && x == uvinf || sign <= 0 && x == uvneginf;
return sign >= 0 && f > MaxFloat64 || sign <= 0 && f < -MaxFloat64
}
-
-// Frexp breaks f into a normalized fraction
-// and an integral power of two.
-// It returns frac and exp satisfying f == frac × 2<sup>exp</sup>,
-// with the absolute value of frac in the interval [½, 1).
-func Frexp(f float64) (frac float64, exp int) {
- // TODO(rsc): Remove manual inlining of IsNaN, IsInf
- // when compiler does it for us
- // special cases
- switch {
- case f == 0:
- return
- case f < -MaxFloat64 || f > MaxFloat64 || f != f: // IsInf(f, 0) || IsNaN(f):
- frac = f
- return
- }
- x := Float64bits(f)
- exp = int((x>>shift)&mask) - bias
- x &^= mask << shift
- x |= bias << shift
- frac = Float64frombits(x)
- return
-}
-
-// Ldexp is the inverse of Frexp.
-// It returns frac × 2<sup>exp</sup>.
-func Ldexp(frac float64, exp int) float64 {
- // TODO(rsc): Remove manual inlining of IsNaN, IsInf
- // when compiler does it for us
- // special cases
- if frac != frac { // IsNaN(frac)
- return NaN()
- }
- x := Float64bits(frac)
- exp += int(x>>shift) & mask
- if exp <= 0 {
- return 0 // underflow
- }
- if exp >= mask { // overflow
- if frac < 0 {
- return Inf(-1)
- }
- return Inf(1)
- }
- x &^= mask << shift
- x |= uint64(exp) << shift
- return Float64frombits(x)
-}