Skip to main content
Helpful?

UnsafeMath

Git Source | Generated with forge doc

Contains methods that perform common math functions but do not do any overflow or underflow checks

Functions

divRoundingUp

Returns ceil(x / y)

division by 0 has unspecified behavior, and must be checked externally

function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z);

Parameters

NameTypeDescription
xuint256The dividend
yuint256The divisor

Returns

NameTypeDescription
zuint256The quotient, ceil(x / y)

simpleMulDiv

Calculates floor(a×b÷denominator)

division by 0 has unspecified behavior, and must be checked externally

function simpleMulDiv(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result);

Parameters

NameTypeDescription
auint256The multiplicand
buint256The multiplier
denominatoruint256The divisor

Returns

NameTypeDescription
resultuint256The 256-bit result, floor(a×b÷denominator)
Helpful?