mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-11 20:20:05 +00:00
21 lines
645 B
Solidity
21 lines
645 B
Solidity
|
pragma solidity ^0.5.1;
|
||
|
|
||
|
library SafeMath {
|
||
|
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
||
|
require(b <= a, "The second parameter can not be greater than first one.");
|
||
|
uint256 c = a - b;
|
||
|
return c;
|
||
|
}
|
||
|
|
||
|
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
||
|
uint256 c = a + b;
|
||
|
require(c >= a, "The first parametert can not be greater than the sum of two parameters");
|
||
|
return c;
|
||
|
}
|
||
|
|
||
|
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
|
||
|
require(b != 0, "The second parameter can not be zero");
|
||
|
return a % b;
|
||
|
}
|
||
|
}
|