Careful Math (CarefulMath.sol)
↗ Extends: ErrorReporter ↘ Derived Contracts: Exponential

Functions

  • mul(uint256 a, uint256 b)
  • div(uint256 a, uint256 b)
  • sub(uint256 a, uint256 b)
  • add(uint256 a, uint256 b)
  • addThenSub(uint256 a, uint256 b, uint256 c)

mul

Multiplies two numbers, returns an error on overflow.
1
function mul(uint256 a, uint256 b) internal pure
2
returns(enum ErrorReporter.Error, uint256)
Copied!
Arguments
Name
Type
Description
a
uint256
b
uint256

div

Integer division of two numbers, truncating the quotient.
1
function div(uint256 a, uint256 b) internal pure
2
returns(enum ErrorReporter.Error, uint256)
Copied!
Arguments
Name
Type
Description
a
uint256
b
uint256

sub

Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend).
1
function sub(uint256 a, uint256 b) internal pure
2
returns(enum ErrorReporter.Error, uint256)
Copied!
Arguments
Name
Type
Description
a
uint256
b
uint256

add

Adds two numbers, returns an error on overflow.
1
function add(uint256 a, uint256 b) internal pure
2
returns(enum ErrorReporter.Error, uint256)
Copied!
Arguments
Name
Type
Description
a
uint256
b
uint256

addThenSub

add a and b and then subtract c
1
function addThenSub(uint256 a, uint256 b, uint256 c) internal pure
2
returns(enum ErrorReporter.Error, uint256)
Copied!
Arguments
Name
Type
Description
a
uint256
b
uint256
c
uint256
Copy link
Contents
Functions