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.
20 lines
487 B
20 lines
487 B
pragma solidity ^0.4.24;
|
|
|
|
/**
|
|
* @title Math
|
|
* @dev Assorted math operations
|
|
*/
|
|
library Math {
|
|
function max(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
return a >= b ? a : b;
|
|
}
|
|
|
|
function min(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
return a < b ? a : b;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|