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

Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).

addUInt

Adds two numbers, returns an error on overflow.

addThenSubUInt

add a and b and then subtract c

min

min and max functions

max

MAXUINT

MAXUINT96

MAXUINT24