You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
809 B
31 lines
809 B
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity >=0.6.0 <0.8.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);
|
|
}
|
|
}
|
|
|