diff options
author | Robert Griesemer <gri@golang.org> | 2013-04-03 13:24:32 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2013-04-03 13:24:32 -0700 |
commit | c97c10fe265c11e367b0d3b1d31edc01f83e48c0 (patch) | |
tree | f18c92252b6545656856a70ed3a5bbbbf7c49ae6 /src/pkg/math/big/rat.go | |
parent | c352ddd5caa42e962926f30e1773535a0074e48d (diff) | |
download | go-c97c10fe265c11e367b0d3b1d31edc01f83e48c0.tar.gz |
math/big: minor cleanups
- comment fixes
- s/z/x/ in (*rat).Float64 to match convention for functions
returning a non-*Rat
- minor test output tweaking
R=golang-dev, r
CC=golang-dev
https://codereview.appspot.com/8327044
Diffstat (limited to 'src/pkg/math/big/rat.go')
-rw-r--r-- | src/pkg/math/big/rat.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/pkg/math/big/rat.go b/src/pkg/math/big/rat.go index 3e6473d92..75d044fe2 100644 --- a/src/pkg/math/big/rat.go +++ b/src/pkg/math/big/rat.go @@ -163,16 +163,16 @@ func quotToFloat(a, b nat) (f float64, exact bool) { return } -// Float64 returns the nearest float64 value to z. -// If z is exactly representable as a float64, Float64 returns exact=true. -// If z is negative, so too is f, even if f==0. -func (z *Rat) Float64() (f float64, exact bool) { - b := z.b.abs +// Float64 returns the nearest float64 value for x and a bool indicating +// whether f represents x exactly. The sign of f always matches the sign +// of x, even if f == 0. +func (x *Rat) Float64() (f float64, exact bool) { + b := x.b.abs if len(b) == 0 { b = b.set(natOne) // materialize denominator } - f, exact = quotToFloat(z.a.abs, b) - if z.a.neg { + f, exact = quotToFloat(x.a.abs, b) + if x.a.neg { f = -f } return |