diff options
Diffstat (limited to 'src/pkg/strconv/ftoa.go')
| -rw-r--r-- | src/pkg/strconv/ftoa.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/pkg/strconv/ftoa.go b/src/pkg/strconv/ftoa.go index b6049c545..07fe806b9 100644 --- a/src/pkg/strconv/ftoa.go +++ b/src/pkg/strconv/ftoa.go @@ -98,7 +98,8 @@ func genericFtoa(bits uint64, fmt byte, prec int, flt *floatInfo) string { // The shift is exp - flt.mantbits because mant is a 1-bit integer // followed by a flt.mantbits fraction, and we are treating it as // a 1+flt.mantbits-bit integer. - d := newDecimal(mant).Shift(exp - int(flt.mantbits)) + d := newDecimal(mant) + d.Shift(exp - int(flt.mantbits)) // Round appropriately. // Negative precision means "only as much as needed to be exact." @@ -183,7 +184,8 @@ func roundShortest(d *decimal, mant uint64, exp int, flt *floatInfo) { // d = mant << (exp - mantbits) // Next highest floating point number is mant+1 << exp-mantbits. // Our upper bound is halfway inbetween, mant*2+1 << exp-mantbits-1. - upper := newDecimal(mant*2 + 1).Shift(exp - int(flt.mantbits) - 1) + upper := newDecimal(mant*2 + 1) + upper.Shift(exp - int(flt.mantbits) - 1) // d = mant << (exp - mantbits) // Next lowest floating point number is mant-1 << exp-mantbits, @@ -201,7 +203,8 @@ func roundShortest(d *decimal, mant uint64, exp int, flt *floatInfo) { mantlo = mant*2 - 1 explo = exp - 1 } - lower := newDecimal(mantlo*2 + 1).Shift(explo - int(flt.mantbits) - 1) + lower := newDecimal(mantlo*2 + 1) + lower.Shift(explo - int(flt.mantbits) - 1) // The upper and lower bounds are possible outputs only if // the original mantissa is even, so that IEEE round-to-even |
