Last active
January 28, 2018 14:39
-
-
Save bitdollarfund/b870e853adf910cc46f358adac44fe28 to your computer and use it in GitHub Desktop.
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.18; | |
contract SafeMath { | |
function safeMul(uint a, uint b) internal pure returns (uint) { | |
uint c = a * b; | |
assert(a == 0 || c / a == b); | |
return c; | |
} | |
function safeSub(uint a, uint b) internal pure returns (uint) { | |
assert(b <= a); | |
return a - b; | |
} | |
function safeAdd(uint a, uint b) internal pure returns (uint) { | |
uint c = a + b; | |
assert(c>=a && c>=b); | |
return c; | |
} | |
modifier onlyPayloadSize(uint numWords) { | |
assert(msg.data.length >= numWords * 32 + 4); | |
_; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment