Skip to main content
Helpful?

LowGasSafeMath

Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost

Functions

add

  function add(
uint256 x,
uint256 y
) internal pure returns (uint256 z)

Returns x + y, reverts if sum overflows uint256

Parameters:

NameTypeDescription
xuint256The augend
yuint256The addend

Return Values:

NameTypeDescription
zuint256The sum of x and y

sub

  function sub(
uint256 x,
uint256 y
) internal pure returns (uint256 z)

Returns x - y, reverts if underflows

Parameters:

NameTypeDescription
xuint256The minuend
yuint256The subtrahend

Return Values:

NameTypeDescription
zuint256The difference of x and y

mul

  function mul(
uint256 x,
uint256 y
) internal pure returns (uint256 z)

Returns x * y, reverts if overflows

Parameters:

NameTypeDescription
xuint256The multiplicand
yuint256The multiplier

Return Values:

NameTypeDescription
zuint256The product of x and y

add

  function add(
int256 x,
int256 y
) internal pure returns (int256 z)

Returns x + y, reverts if overflows or underflows

Parameters:

NameTypeDescription
xint256The augend
yint256The addend

Return Values:

NameTypeDescription
zint256The sum of x and y

sub

  function sub(
int256 x,
int256 y
) internal pure returns (int256 z)

Returns x - y, reverts if overflows or underflows

Parameters:

NameTypeDescription
xint256The minuend
yint256The subtrahend

Return Values:

NameTypeDescription
zint256The difference of x and y
Helpful?