mirror of
https://github.com/shopspring/decimal.git
synced 2024-11-25 05:40:49 +01:00
Compare commits
2 commits
d538aec685
...
20bfa00fcd
Author | SHA1 | Date | |
---|---|---|---|
|
20bfa00fcd | ||
|
445700e706 |
2 changed files with 2 additions and 1 deletions
|
@ -1231,6 +1231,7 @@ func (d Decimal) NumDigits() int {
|
||||||
|
|
||||||
if d.value.IsInt64() {
|
if d.value.IsInt64() {
|
||||||
i64 := d.value.Int64()
|
i64 := d.value.Int64()
|
||||||
|
// restrict fast path to integers with exact conversion to float64
|
||||||
if i64 <= (1<<53) && i64 >= -(1<<53) {
|
if i64 <= (1<<53) && i64 >= -(1<<53) {
|
||||||
if i64 == 0 {
|
if i64 == 0 {
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -125,7 +125,7 @@ func numDigits(b *testing.B, want int, val Decimal) {
|
||||||
b.Helper()
|
b.Helper()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
if have := val.NumDigits(); have != want {
|
if have := val.NumDigits(); have != want {
|
||||||
b.Fatalf("\nHave: %q\nWant: %q", have, want)
|
b.Fatalf("\nHave: %d\nWant: %d", have, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue