internal/number: enable the fast case more often
Change-Id: I0849b029eee7b233f4c6f676d7bbdde3820c63e4
Reviewed-on: https://go-review.googlesource.com/46470
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
diff --git a/internal/number/decimal.go b/internal/number/decimal.go
index eedc76f..f0a5777 100644
--- a/internal/number/decimal.go
+++ b/internal/number/decimal.go
@@ -347,7 +347,7 @@
return
}
// Simple case: decimal notation
- if r.Scale > 0 || r.Increment > 0 && r.Scale == 0 {
+ if r.Scale > 0 || r.Increment > 0 || r.Precision == 0 {
if int(r.Scale) > len(scales) {
x *= math.Pow(10, float64(r.Scale))
} else {
@@ -372,6 +372,7 @@
// TODO: expose functionality in strconv so we can avoid this hack.
// Something like this would work:
// AppendDigits(dst []byte, x float64, base, size, prec int) (digits []byte, exp, accuracy int)
+ // TODO: This only supports the nearest even rounding mode.
prec := int(r.Precision)
if prec > 0 {