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.
32 lines
801 B
32 lines
801 B
5 years ago
|
// SPDX-License-Identifier: MIT
|
||
|
|
||
4 years ago
|
pragma solidity ^0.8.0;
|
||
8 years ago
|
|
||
|
/**
|
||
6 years ago
|
* @dev Standard math utilities missing in the Solidity language.
|
||
8 years ago
|
*/
|
||
8 years ago
|
library Math {
|
||
6 years ago
|
/**
|
||
6 years ago
|
* @dev Returns the largest of two numbers.
|
||
|
*/
|
||
6 years ago
|
function max(uint256 a, uint256 b) internal pure returns (uint256) {
|
||
|
return a >= b ? a : b;
|
||
|
}
|
||
8 years ago
|
|
||
6 years ago
|
/**
|
||
6 years ago
|
* @dev Returns the smallest of two numbers.
|
||
|
*/
|
||
6 years ago
|
function min(uint256 a, uint256 b) internal pure returns (uint256) {
|
||
|
return a < b ? a : b;
|
||
|
}
|
||
7 years ago
|
|
||
6 years ago
|
/**
|
||
6 years ago
|
* @dev Returns the average of two numbers. The result is rounded towards
|
||
|
* zero.
|
||
6 years ago
|
*/
|
||
6 years ago
|
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);
|
||
|
}
|
||
8 years ago
|
}
|