SafeMath.sol
library SafeMath
Math operations with safety checks that revert on error.Source: Libraries/SafeMath.sol
Index
Reference
Functions
add
function
add
(uint256 a, uint256 b) internal pure returns (uint256)
Adds two numbers, reverts on overflow.Parameters:
a
- uint256b
- uint256Returns:uint256div
function
div
(uint256 a, uint256 b) internal pure returns (uint256)
Integer division of two numbers truncating the quotient, reverts on division by zero.Parameters:
a
- uint256b
- uint256Returns:uint256mod
function
mod
(uint256 a, uint256 b) internal pure returns (uint256)
Divides two numbers and returns the remainder (unsigned integer modulo), reverts when dividing by zero.Parameters:
a
- uint256b
- uint256Returns:uint256mul
function
mul
(uint256 a, uint256 b) internal pure returns (uint256)
Multiplies two numbers, reverts on overflow.Parameters:
a
- uint256b
- uint256Returns:uint256sub
function
sub
(uint256 a, uint256 b) internal pure returns (uint256)
Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).Parameters:
a
- uint256b
- uint256Returns:uint256
Last updated
Was this helpful?