Best practice for handling percentages

aja asked on Telegram

hey so I was just wondering what best practice is for handling percentages. I’m using SafeMath for uint256, would percetage = number.mul(%) be okay to do?

If you were were using SafeMath, then your calculations would all be in integers, so you would need to be aware of rounding issues.

There is a discussion on designing a fixed point math library for OpenZeppelin Contracts that I suggest reading:

I also recommend watching Austin’s video on Computing and accumulating interesting on chain:

1 Like