Commit graph

6 commits

Author SHA1 Message Date
Philip Dubé
6e15183b56 Optimize NumDigits
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
2024-03-28 19:49:01 +00:00
Mateusz Woś
46544472a5
Add implementation of natural exponent function (Taylor, Hull-Abraham) (#229)
* Add implementation of natural exponent function (Taylor, Hull-Abraham)
* Update docs
* Improve docs, handle multithreading race condition in exp method
2021-10-11 18:39:38 +02:00
nknordeen
0cada0bdfe
optimize NewFromString a bit (#198)
* optimize NewFromString a bit

* add benchmark for large number

Co-authored-by: Nicholas Nordeen <nnordeen@fanatics.com>
2021-01-09 23:15:12 -05:00
Mateusz Woś
6fe01c1abd
Implement IsInteger method (#179) 2020-07-01 01:20:32 +02:00
Jason Biegel
6c07c6ca86
remove 15 interval RoundCash (#166)
* remove 15 interval RoundCash

* update function doc

* Remove comments and benchmark referring interval 15

Co-authored-by: Mateusz Woś <wos.mateusz16@gmail.com>
2020-02-25 19:44:03 -05:00
Mateusz Woś
408a2507e1
Remove unnecessary decimal rescaling - memory usage optimization (#160)
* Remove unnecessary decimal rescaling

* Move benchmarks to separate file, add new benchmark tests
2020-01-06 00:12:15 +01:00