CappedMath

Git Source

Math operations with caps for under and overflow.

State Variables

UINT_MAX

uint256 private constant UINT_MAX = type(uint256).max;

Functions

addCap

Adds two unsigned integers, returns 2^256 - 1 on overflow.

function addCap(uint256 _a, uint256 _b) internal pure returns (uint256);

subCap

Subtracts two integers, returns 0 on underflow.

function subCap(uint256 _a, uint256 _b) internal pure returns (uint256);

mulCap

Multiplies two unsigned integers, returns 2^256 - 1 on overflow.

function mulCap(uint256 _a, uint256 _b) internal pure returns (uint256);