aboutsummaryrefslogtreecommitdiff
path: root/src/math/big/float.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2015-02-13 17:57:26 -0800
committerRobert Griesemer <gri@golang.org>2015-02-24 17:35:25 +0000
commitd9859ad40438cc27415ec294e9a06bb58fa24e9a (patch)
treecdd19a42e88c2383203e2549567afe3f9a02f4f0 /src/math/big/float.go
parent291bf1f03feece8360e080856e835bcc2cd1f521 (diff)
downloadgo-d9859ad40438cc27415ec294e9a06bb58fa24e9a.tar.xz
math/big: fix several issues with string->Float conversion
Change-Id: I7bf7154e2d8d779fdf7f1d2bb561a06ad174f3b0 Reviewed-on: https://go-review.googlesource.com/4883 Reviewed-by: Alan Donovan <adonovan@google.com>
Diffstat (limited to 'src/math/big/float.go')
-rw-r--r--src/math/big/float.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/math/big/float.go b/src/math/big/float.go
index 47755f2719..a89ef1021a 100644
--- a/src/math/big/float.go
+++ b/src/math/big/float.go
@@ -537,7 +537,7 @@ func (z *Float) SetFloat64(x float64) *Float {
// fnorm normalizes mantissa m by shifting it to the left
// such that the msb of the most-significant word (msw) is 1.
// It returns the shift amount. It assumes that len(m) != 0.
-func fnorm(m nat) uint {
+func fnorm(m nat) int64 {
if debugFloat && (len(m) == 0 || m[len(m)-1] == 0) {
panic("msw of mantissa is 0")
}
@@ -548,7 +548,7 @@ func fnorm(m nat) uint {
panic("nlz or shlVU incorrect")
}
}
- return s
+ return int64(s)
}
// SetInt sets z to the (possibly rounded) value of x and returns z.
@@ -884,7 +884,7 @@ func (z *Float) uadd(x, y *Float) {
}
// len(z.mant) > 0
- z.setExp(ex + int64(len(z.mant))*_W - int64(fnorm(z.mant)))
+ z.setExp(ex + int64(len(z.mant))*_W - fnorm(z.mant))
z.round(0)
}
@@ -926,7 +926,7 @@ func (z *Float) usub(x, y *Float) {
}
// len(z.mant) > 0
- z.setExp(ex + int64(len(z.mant))*_W - int64(fnorm(z.mant)))
+ z.setExp(ex + int64(len(z.mant))*_W - fnorm(z.mant))
z.round(0)
}
@@ -947,7 +947,7 @@ func (z *Float) umul(x, y *Float) {
z.mant = z.mant.mul(x.mant, y.mant)
// normalize mantissa
- z.setExp(e - int64(fnorm(z.mant)))
+ z.setExp(e - fnorm(z.mant))
z.round(0)
}
@@ -986,7 +986,7 @@ func (z *Float) uquo(x, y *Float) {
e := int64(x.exp) - int64(y.exp) - int64(d-len(z.mant))*_W
// normalize mantissa
- z.setExp(e - int64(fnorm(z.mant)))
+ z.setExp(e - fnorm(z.mant))
// The result is long enough to include (at least) the rounding bit.
// If there's a non-zero remainder, the corresponding fractional part