-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BigNumber issue with the AbiCoder. #418
Comments
You cannot use ieee 754 numbers that require more than 53 bits of mantissa. This has been the case in ethers since version 0, years ago. :) Numbers larger than Number.MAX_SAFE_INTEGER are not tightly packed, so will be imprecise, leading to 50% of the time having dust, 50% being too small. To solve this, keep in mind to use strings (decimal or 0x prefixed hex) and do all math using big numbers. Here is some documentation: https://docs.ethers.io/ethers.js/html/notes.html#why-can-t-i-just-use-numbers 10e16 is about the cut off point, since it is 2 ** 53, which is the mantissa limit for 64 bit floating points. This is a very intentional feature, not a bug. ;) |
Closing this now, but please feel free to add comments and ask questions. Or re-open if you would like to bring more attention to this for other watchers to contribute to. :) Thanks! :) |
@ricmoo Thanks for the detailed information I will read your documentation 💪 |
I have this issue of bigNumber and it only perculiar with ios devices. My code is working smoothly with android, windows except ios. here is the error in iOS devices--> let date = (new Date(date_time)).getTime(); //date_time is a dateString in the form of "2022-04-12 19:00:00" This snippet above is pretty much working in android and windows except iOS. |
As already discussed here in the Web3.js issue: web3/web3.js#2077 does the new AbiCoder have problems with converting numbers to BigNumbers and encoding them correctly.
Because Web3.js is just passing the value to the ABI coder does this looks like an issue of ethers.js.
@ricmoo Do you have any additional information about this?
The text was updated successfully, but these errors were encountered: