| layout | title |
|---|---|
default |
CarefulMath |
View Source: contracts/CarefulMath.sol
↗ Extends: ErrorReporter ↘ Derived Contracts: Exponential
{{ContractName}}
Derived from OpenZeppelin's SafeMath library https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol
- mul(uint256 a, uint256 b)
- div(uint256 a, uint256 b)
- sub(uint256 a, uint256 b)
- subInt(uint256 a, uint256 b)
- add(uint256 a, uint256 b)
- addInt(uint256 a, int256 b)
- addThenSub(uint256 a, uint256 b, uint256 c)
Multiplies two numbers, returns an error on overflow.
function mul(uint256 a, uint256 b) internal pure
returns(enum ErrorReporter.Error, uint256)Arguments
| Name | Type | Description |
|---|---|---|
| a | uint256 | |
| b | uint256 |
Integer division of two numbers, truncating the quotient.
function div(uint256 a, uint256 b) internal pure
returns(enum ErrorReporter.Error, uint256)Arguments
| Name | Type | Description |
|---|---|---|
| a | uint256 | |
| b | uint256 |
Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).
function sub(uint256 a, uint256 b) internal pure
returns(enum ErrorReporter.Error, uint256)Arguments
| Name | Type | Description |
|---|---|---|
| a | uint256 | |
| b | uint256 |
Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).
function subInt(uint256 a, uint256 b) internal pure
returns(enum ErrorReporter.Error, int256)Arguments
| Name | Type | Description |
|---|---|---|
| a | uint256 | |
| b | uint256 |
Adds two numbers, returns an error on overflow.
function add(uint256 a, uint256 b) internal pure
returns(enum ErrorReporter.Error, uint256)Arguments
| Name | Type | Description |
|---|---|---|
| a | uint256 | |
| b | uint256 |
Adds two numbers, returns an error on overflow.
function addInt(uint256 a, int256 b) internal pure
returns(enum ErrorReporter.Error, int256)Arguments
| Name | Type | Description |
|---|---|---|
| a | uint256 | |
| b | int256 |
add a and b and then subtract c
function addThenSub(uint256 a, uint256 b, uint256 c) internal pure
returns(enum ErrorReporter.Error, uint256)Arguments
| Name | Type | Description |
|---|---|---|
| a | uint256 | |
| b | uint256 | |
| c | uint256 |