CarefulMath
CarefulMathβ
Derived from OpenZeppelin's SafeMath library https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol
MathErrorβ
Possible error codes that we can return
enum MathError {
NO_ERROR,
DIVISION_BY_ZERO,
INTEGER_OVERFLOW,
INTEGER_UNDERFLOW
}
mulUIntβ
function mulUInt(uint256 a, uint256 b) internal pure returns (enum CarefulMath.MathError, uint256)
Multiplies two numbers, returns an error on overflow.
divUIntβ
function divUInt(uint256 a, uint256 b) internal pure returns (enum CarefulMath.MathError, uint256)
Integer division of two numbers, truncating the quotient.
subUIntβ
function subUInt(uint256 a, uint256 b) internal pure returns (enum CarefulMath.MathError, uint256)
Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).
addUIntβ
function addUInt(uint256 a, uint256 b) internal pure returns (enum CarefulMath.MathError, uint256)
Adds two numbers, returns an error on overflow.
addThenSubUIntβ
function addThenSubUInt(uint256 a, uint256 b, uint256 c) internal pure returns (enum CarefulMath.MathError, uint256)
add a and b and then subtract c
minβ
function min(uint256 a, uint256 b) internal pure returns (uint256)
min and max functions
maxβ
function max(uint256 a, uint256 b) internal pure returns (uint256)
MAXUINTβ
uint256 MAXUINT
MAXUINT96β
uint256 MAXUINT96
MAXUINT24β
uint256 MAXUINT24