Last active
July 2, 2018 14:49
-
-
Save colus001/40dc161ab9c776c30c7ef9f089d31c64 to your computer and use it in GitHub Desktop.
Implemetation of JS Math.min and Math.max
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.23; | |
/** | |
* @title Math | |
* @dev Javascript Math.min and Math.max implementation | |
*/ | |
library Math { | |
/** | |
* @dev Retreive smaller value from two parameters | |
*/ | |
function min(uint a, uint b) internal pure returns (uint) { | |
return a < b ? a : b; | |
} | |
/** | |
* @dev Retreive bigger value from two parameters | |
*/ | |
function max(uint a, uint b) internal pure returns (uint) { | |
return a > b ? a : b; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment