Skip to content

Commit

Permalink
Decimal: handle %s format in (*Decimal).Format
Browse files Browse the repository at this point in the history
  • Loading branch information
db47h committed May 24, 2020
1 parent 7d50a13 commit bd1bb29
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion decimal_toa.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func (x *Decimal) fmtP(buf []byte) []byte {
buf = append(buf, "0."...)
mant, exp := x.toa(10)
buf = append(buf, bytes.TrimRight(mant, "0")...)
buf = append(buf, 'p')
buf = append(buf, 'e')
if x.exp >= 0 {
buf = append(buf, '+')
}
Expand All @@ -371,6 +371,11 @@ func (x *Decimal) Format(s fmt.State, format rune) {
case 'F':
// (*Decimal).Text doesn't support 'F'; handle like 'f'
format = 'f'
case 's':
format = 'g'
if !hasPrec {
prec = 10
}
case 'v':
// handle like 'g'
format = 'g'
Expand Down

0 comments on commit bd1bb29

Please sign in to comment.