Skip to content

Instantly share code, notes, and snippets.

@colus001
Last active July 2, 2018 14:49
Show Gist options
  • Save colus001/40dc161ab9c776c30c7ef9f089d31c64 to your computer and use it in GitHub Desktop.
Save colus001/40dc161ab9c776c30c7ef9f089d31c64 to your computer and use it in GitHub Desktop.
Implemetation of JS Math.min and Math.max
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