joule-labs / webln-docs

Documentation for the WebLN library & spec, at https://webln.dev
https://webln.dev
11 stars 14 forks source link

In JavaScript integers are 53-bit... #1

Closed Perlover closed 1 year ago

Perlover commented 5 years ago

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

Perlover commented 5 years ago

And second doc of ECMAScript 2015:

https://www.ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer

Perlover commented 5 years ago

And if your amount in satoshies, so if we have 21E6 bitcoins * 1E8 for this amount will be enough 51 bits maximum:

ln(21E6 * 1E8)/ln(2) = 50.8

Thus we can safely say that the type Number() will be enough for amount in satoshies...

wbobeirne commented 5 years ago

Ah, you're totally right on that. I think I was mistaken by the fact that bitwise operations are limited to 32 bits. I'll review the code and make sure there's nowhere that allowing numbers would be problematic.