decimal
decimal copied to clipboard
[Bug] (decimal.Decimal{}).NumDigits == 5
code in decimal
func (d Decimal) NumDigits() int {
// Note(mwoss): It can be optimized, unnecessary cast of big.Int to string
if d.IsNegative() {
return len(d.value.String()) - 1
}
return len(d.value.String())
}
when d.value
is nil, d.value.String() return "<nil>"
instead of "0"
func (x *Int) Text(base int) string {
if x == nil {
return "<nil>"
}
return string(x.abs.itoa(x.neg, base))
}
// String returns the decimal representation of x as generated by
// x.Text(10).
func (x *Int) String() string {
return x.Text(10)
}
Please add more test cases for decimal.Decimal{}
Thanks for the report! The issue has been fixed via #301 and will be included in the next release.