Skip to content
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

Multiplication of two positive numbers can result in zero #13

Closed
tinchoabbate opened this issue Oct 11, 2019 · 1 comment
Closed

Multiplication of two positive numbers can result in zero #13

tinchoabbate opened this issue Oct 11, 2019 · 1 comment

Comments

@tinchoabbate
Copy link

tinchoabbate commented Oct 11, 2019

The wmul function does not behave as expected in certain cases. In particular, the multiplication of two positive numbers can result in zero. That is true for every a,b > 0 and b < 5*10^17 / a (as shown here).

In such cases, I was expecting the wmul function to revert the transaction instead of returning 0.
Were you aware of this behavior ? If you were, are you planning to modify the library ? I believe the way to go, for a far more reasonable behavior, would be to either revert the transaction if there's a rounding to 0, or properly document this unexpected behavior in the function's docs.

Note that a similar issue happens in rmul

@livnev
Copy link
Member

livnev commented Mar 10, 2021

Rounding to 0 when the result of the multiplication is less than 0.0000000000000000005 is expected behaviour, so that is not a bug. If that is a problem for the application, then it should be checked explicitly.

@livnev livnev closed this as completed Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants