SignedMath
Standard signed math utilities missing in the Solidity language.
Functions
ternary
Branchless ternary evaluation for a ? b : c. Gas costs are constant.
IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
However, the compiler may optimize Solidity ternary operations (i.e. a ? b : c) to only compute
one branch when needed, making this function more expensive.
function ternary(bool condition, int256 a, int256 b) internal pure returns (int256);
max
Returns the largest of two signed numbers.
function max(int256 a, int256 b) internal pure returns (int256);
min
Returns the smallest of two signed numbers.
function min(int256 a, int256 b) internal pure returns (int256);
average
Returns the average of two signed numbers without overflow. The result is rounded towards zero.
function average(int256 a, int256 b) internal pure returns (int256);
abs
Returns the absolute unsigned value of a signed value.
function abs(int256 n) internal pure returns (uint256);