diff options
author | Ian Lance Taylor <iant@google.com> | 2011-01-21 18:19:03 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-01-21 18:19:03 +0000 |
commit | ff5f50c52c421d75940ef9392211e3ab24d71332 (patch) | |
tree | 27d8768fb1d25696d3c40b42535eb5e073c278da /libgo/go/math/bits.go | |
parent | d6ed1c8903e728f4233122554bab5910853338bd (diff) | |
download | gcc-ff5f50c52c421d75940ef9392211e3ab24d71332.tar.gz |
Remove the types float and complex.
Update to current version of Go library.
Update testsuite for removed types.
* go-lang.c (go_langhook_init): Omit float_type_size when calling
go_create_gogo.
* go-c.h: Update declaration of go_create_gogo.
From-SVN: r169098
Diffstat (limited to 'libgo/go/math/bits.go')
-rw-r--r-- | libgo/go/math/bits.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libgo/go/math/bits.go b/libgo/go/math/bits.go index d36cd18d76b..a1dca3ed695 100644 --- a/libgo/go/math/bits.go +++ b/libgo/go/math/bits.go @@ -10,7 +10,7 @@ const ( uvneginf = 0xFFF0000000000000 mask = 0x7FF shift = 64 - 11 - 1 - bias = 1022 + bias = 1023 ) // Inf returns positive infinity if sign >= 0, negative infinity if sign < 0. @@ -47,3 +47,13 @@ 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 } + +// normalize returns a normal number y and exponent exp +// satisfying x == y × 2**exp. It assumes x is finite and non-zero. +func normalize(x float64) (y float64, exp int) { + const SmallestNormal = 2.2250738585072014e-308 // 2**-1022 + if Fabs(x) < SmallestNormal { + return x * (1 << 52), -52 + } + return x, 0 +} |