You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.6 KiB
68 lines
1.6 KiB
5 years ago
|
// SPDX-License-Identifier: MIT
|
||
|
|
||
4 years ago
|
pragma solidity ^0.8.0;
|
||
6 years ago
|
|
||
|
/**
|
||
4 years ago
|
* @dev Wrappers over Solidity's arithmetic operations.
|
||
|
*
|
||
|
* NOTE: `SignedSafeMath` is no longer needed starting with Solidity 0.8. The compiler
|
||
|
* now has built in overflow checking.
|
||
6 years ago
|
*/
|
||
|
library SignedSafeMath {
|
||
4 years ago
|
/**
|
||
5 years ago
|
* @dev Returns the multiplication of two signed integers, reverting on
|
||
|
* overflow.
|
||
|
*
|
||
|
* Counterpart to Solidity's `*` operator.
|
||
|
*
|
||
|
* Requirements:
|
||
|
*
|
||
|
* - Multiplication cannot overflow.
|
||
6 years ago
|
*/
|
||
6 years ago
|
function mul(int256 a, int256 b) internal pure returns (int256) {
|
||
4 years ago
|
return a * b;
|
||
6 years ago
|
}
|
||
|
|
||
|
/**
|
||
5 years ago
|
* @dev Returns the integer division of two signed integers. Reverts on
|
||
|
* division by zero. The result is rounded towards zero.
|
||
|
*
|
||
4 years ago
|
* Counterpart to Solidity's `/` operator.
|
||
5 years ago
|
*
|
||
|
* Requirements:
|
||
|
*
|
||
|
* - The divisor cannot be zero.
|
||
6 years ago
|
*/
|
||
6 years ago
|
function div(int256 a, int256 b) internal pure returns (int256) {
|
||
4 years ago
|
return a / b;
|
||
6 years ago
|
}
|
||
|
|
||
|
/**
|
||
5 years ago
|
* @dev Returns the subtraction of two signed integers, reverting on
|
||
|
* overflow.
|
||
|
*
|
||
|
* Counterpart to Solidity's `-` operator.
|
||
|
*
|
||
|
* Requirements:
|
||
|
*
|
||
|
* - Subtraction cannot overflow.
|
||
6 years ago
|
*/
|
||
6 years ago
|
function sub(int256 a, int256 b) internal pure returns (int256) {
|
||
4 years ago
|
return a - b;
|
||
6 years ago
|
}
|
||
|
|
||
|
/**
|
||
5 years ago
|
* @dev Returns the addition of two signed integers, reverting on
|
||
|
* overflow.
|
||
|
*
|
||
|
* Counterpart to Solidity's `+` operator.
|
||
|
*
|
||
|
* Requirements:
|
||
|
*
|
||
|
* - Addition cannot overflow.
|
||
6 years ago
|
*/
|
||
6 years ago
|
function add(int256 a, int256 b) internal pure returns (int256) {
|
||
4 years ago
|
return a + b;
|
||
6 years ago
|
}
|
||
|
}
|