Closed CidTori closed 5 years ago
Not only does the base have to be a safe integer, but with the way the library works, operations on digits have to also be safe integers.
That is, if I have digits a and b, a + b and a*b also have to be safe integers.
Thanks for your quick answer, I didn't think about that. And just out of curiosity, why didn't you choose 94906265 (which is floor(sqrt(2^53-1))? And why did you choose a power of 10 instead of, for example, a power of 2?
I chose the largest power of 10 below 94906265.
I chose a power of 10 because parsing a base-10 string and converting a big integer to a base-10 string are some of the most common operations users do. In base 94906265 some arithmetic operations might be slightly faster due to fewer digits (but not significantly fewer), but it would take much longer to convert base-10 number strings to and from base 94906265.
It makes sense, thanks!
Are there any reason to choose that seemingly random number instead of, for example, Number.MAX_SAFE_INTEGER === 2^53-1 which should optimize memory use?