Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dividing BitLen by math.Log2(10) is what math/big does underneath Not including the Int64/Uint64 check makes this slightly slower than old method Included 2 benchmarks, for 10 digit numbers & 100 digit numbers: -- before > go test -bench=NumDigit -run=NumDigit goos: linux goarch: amd64 pkg: github.com/shopspring/decimal cpu: AMD Ryzen 7 7840U w/ Radeon 780M Graphics BenchmarkDecimal_NumDigits10-16 18317293 63.87 ns/op BenchmarkDecimal_NumDigits100-16 3645015 329.6 ns/op -- after ... BenchmarkDecimal_NumDigits10-16 143781325 8.488 ns/op BenchmarkDecimal_NumDigits100-16 5931247 207.4 ns/op
- Loading branch information
Showing
2 changed files
with
59 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters