Closed guidovranken closed 4 years ago
No, it shouldn't print that.
It should print
43588989435406735522369819838596156591370039252324449368903441381595573282031580856561591558519445269056586212982742136295839927838261170121565608364174699009777529188794058900619967156631207402231024023243567359810484091999315007271878765
What software are you using to check the result?
There are limits to sqrt, but I am not sure where they are exactly.
I'll look into into it at some point. Thanks for the report.
Fixed in v9.0.1.
Do you have any further details or perhaps code to share regarding the tests that you have performed here?
Regardless, thanks again for the report, as this bug also affects my other library decimal.js.
Notes:
This bug was fixed by just changing a single character. It only appeared when taking the square root of a number with more than 308 integer digits when the digits were 19
followed by zeros for at least half the number of the remaining digits. The bug was caused by a difficult-to-foresee problem with the initial square root estimate, which for smaller numbers is instead performed with Math.sqrt
.
@MikeMcl thanks for fixing it!
My project Cryptofuzz generates random numbers and performs the same calculation on those numbers in different libraries. Currently about 30 different libraries are supported: https://github.com/guidovranken/cryptofuzz/tree/master/modules
The harness code for bignumber.js is here: https://github.com/guidovranken/cryptofuzz/blob/master/modules/bignumber.js/harness.js
FuzzerInput
)FuzzerOutput
Cryptofuzz then compares the result to that of eg. OpenSSL, and alerts you if it finds a discrepancy.
What else would you like to know? If you would like to run it yourself, I can make a build script for you.
Great project!
Thanks for the info. I'll take a good look when time permits.
This prints:
but it should print: