decimal
decimal copied to clipboard
Added Sqrt and SqrtRound functionality
Based this on https://github.com/shopspring/decimal/pull/111 , but corrected an algorithmic bug.
Not sure why those other changes are showing up.
I need decimal to be sqrt(), it's current missed, please merge the function
The implementation overall looks good. If you can @ldcicconi, please rebase it so I can merge it to master and add unit tests for this implementation. If you don't have time I can do it and write unit tests for this implementation.
@mwoss on it.
@mwoss I added some unit tests and made a few other changes. Let me know what you think.
note: the second test case in the vals
map currently fails. I must be missing something for numbers near 0.
Hmm, I'm not sure why this algorithm is failing on numbers in the range (0, 1). What method you have used for calculating sqrt? Can you point me to the paper or any article?
Can we get this PR merged? The code looks good, only issue is a couple digit off, and it's way more than enough for most use cases. #222
decimal_test.go:2913: Square root of 0.002342 should be 0.0483942145302514, not 0.0483942145302509 (error: %!s(
thanks