aboutsummaryrefslogtreecommitdiff
path: root/src/fmt/format.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/fmt/format.go')
-rw-r--r--src/fmt/format.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/fmt/format.go b/src/fmt/format.go
index ba984cf84f..ac9f6d881a 100644
--- a/src/fmt/format.go
+++ b/src/fmt/format.go
@@ -162,6 +162,11 @@ func (f *fmt) integer(a int64, base uint64, signedness bool, digits string) {
return
}
+ negative := signedness == signed && a < 0
+ if negative {
+ a = -a
+ }
+
var buf []byte = f.intbuf[0:]
if f.widPresent || f.precPresent || f.plus || f.space {
width := f.wid + f.prec // Only one will be set, both are positive; this provides the maximum.
@@ -177,9 +182,7 @@ func (f *fmt) integer(a int64, base uint64, signedness bool, digits string) {
width += 1 + 1 + utf8.UTFMax + 1
}
}
- if f.plus {
- width++
- } else if f.space {
+ if negative || f.plus || f.space {
width++
}
if width > nByte {
@@ -188,11 +191,6 @@ func (f *fmt) integer(a int64, base uint64, signedness bool, digits string) {
}
}
- negative := signedness == signed && a < 0
- if negative {
- a = -a
- }
-
// two ways to ask for extra leading zero digits: %.3d or %03d.
// apparently the first cancels the second.
prec := 0