|
|
@ -11,9 +11,13 @@ library SafeMath { |
|
|
|
* @dev Multiplies two numbers, throws on overflow. |
|
|
|
* @dev Multiplies two numbers, throws on overflow. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { |
|
|
|
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { |
|
|
|
|
|
|
|
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the |
|
|
|
|
|
|
|
// benefit is lost if 'b' is also tested. |
|
|
|
|
|
|
|
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 |
|
|
|
if (a == 0) { |
|
|
|
if (a == 0) { |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
c = a * b; |
|
|
|
c = a * b; |
|
|
|
assert(c / a == b); |
|
|
|
assert(c / a == b); |
|
|
|
return c; |
|
|
|
return c; |
|
|
|