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

SafeMath does not provide detection of losing precision by division #1759

Closed
guylando opened this issue May 18, 2019 · 2 comments
Closed

SafeMath does not provide detection of losing precision by division #1759

guylando opened this issue May 18, 2019 · 2 comments

Comments

@guylando
Copy link

The name SafeMath can make developers use it without paying attention of problem of division losing precision https://consensys.github.io/smart-contract-best-practices/recommendations/#beware-rounding-with-integer-division
Maybe add a function "safediv" which also checks that precision wasn't lost and add in documentation of "div" that precision can be lost.

@Skyge
Copy link
Contributor

Skyge commented May 23, 2019

As long as you do a division, there is a possible to loss precision. I think adding a @notice message is good, it can remind people of this point.

@nventuro
Copy link
Contributor

This loss of precision is intrinsically associated with integer division, and would be surprised to learn that someone understood the 'safe' part as being related to it. Besides, SafeMath's documentation makes it very clear that it has to do with overflow protection.

We are, however, considering adding fixed-point support! Please join the discussion in the forum: https://forum.zeppelin.solutions/t/fixed-point-arithmetic-support/356

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

3 participants