-
Issue DescriptionTake the following negative big number:
Which happens to be the minimum value permitted by int156. If one takes the modulo 1e18 of this number, one gets a different result in Ethers.js compared to what Solidity produces. Solidity
Which yields:
Ethers.Js
Which yields:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
That is correct. :) The ethers BigNumber always returns a positive number in the range [0, N). Solidity (and EVM's SMOD) uses the C If you want to mimic Solidity's behaviour, you can use a method similar to:
Does that make sense? |
Beta Was this translation helpful? Give feedback.
-
(moving to discussions) |
Beta Was this translation helpful? Give feedback.
-
Idea: what if the |
Beta Was this translation helpful? Give feedback.
That is correct. :)
The ethers BigNumber always returns a positive number in the range [0, N). Solidity (and EVM's SMOD) uses the C
fmod
-style method, which returns a value with the same sign asvalue
.If you want to mimic Solidity's behaviour, you can use a method similar to:
Does that make sense?