Skip to main content

MathUtils

A library to be used in conjunction with SafeMath. Contains functions for calculating differences between two uint256.

Functions#

within1#

function within1(
uint256 a,
uint256 b
) external returns (bool)

Compares a and b and returns true if the difference between a and b is less than 1 or equal to each other.

Parameters:#

NameTypeDescription
auint256uint256 to compare with
buint256uint256 to compare with

Return Values:#

NameTypeDescription
Trueuint256if the difference between a and b is less than 1 or equal,
otherwise return false

difference#

function difference(
uint256 a,
uint256 b
) external returns (uint256)

Calculates absolute difference between a and b

Parameters:#

NameTypeDescription
auint256uint256 to compare with
buint256uint256 to compare with

Return Values:#

NameTypeDescription
Differenceuint256between a and b

_difference#

function _difference(
uint256 a,
uint256 b
) internal returns (uint256)

Calculates absolute difference between a and b

Parameters:#

NameTypeDescription
auint256uint256 to compare with
buint256uint256 to compare with

Return Values:#

NameTypeDescription
Differenceuint256between a and b