Closed
Description
When using the RoundTo method with a precision of 8 and RoundHalfUp rounding mode on a zero amount, the Number method returns "0E-8" instead of "0.00000000". This inconsistency in formatting can cause confusion. Here's a snippet to reproduce the issue:
package main
import (
"fmt"
"github.com/bojanz/currency"
)
func main() {
c, _ := currency.NewAmountFromInt64(0, "SEK")
c = c.RoundTo(8, currency.RoundHalfUp)
fmt.Printf("%s\n", c.Number())
}
The apd.Decimal String() defaults to use d.Text('G') which is intended?
// 'G' like 'E' for large exponents, like 'f' otherwise
One fix would be to change Number() to use apd.Decimal.Text('f') method but that will be a breaking change
It would be nice to be able to output Number() without exponents.
Metadata
Assignees
Labels
No labels
Activity