math overflow fix

This commit is contained in:
owen05
2020-12-30 23:23:20 +08:00
parent c717e5fb9b
commit f81e5481f8
3 changed files with 15 additions and 2 deletions

View File

@@ -32,6 +32,11 @@ library SafeMath {
return a / b;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "MOD_ERROR");
return a % b;
}
function divCeil(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 quotient = div(a, b);
uint256 remainder = a - quotient * b;