735546619e
Signed-off-by: T-Hax <>
32 lines
801 B
Solidity
32 lines
801 B
Solidity
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity ^0.6.0;
|
|
|
|
/**
|
|
* @dev Standard math utilities missing in the Solidity language.
|
|
*/
|
|
library Math {
|
|
/**
|
|
* @dev Returns the largest of two numbers.
|
|
*/
|
|
function max(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
return a >= b ? a : b;
|
|
}
|
|
|
|
/**
|
|
* @dev Returns the smallest of two numbers.
|
|
*/
|
|
function min(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
return a < b ? a : b;
|
|
}
|
|
|
|
/**
|
|
* @dev Returns the average of two numbers. The result is rounded towards
|
|
* zero.
|
|
*/
|
|
function average(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
// (a + b) / 2 can overflow, so we distribute
|
|
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
|
|
}
|
|
}
|