Reorganize the repo structure (#2503)
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This commit is contained in:
67
contracts/utils/math/SignedSafeMath.sol
Normal file
67
contracts/utils/math/SignedSafeMath.sol
Normal file
@ -0,0 +1,67 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
library SignedSafeMath {
|
||||
/**
|
||||
* @dev Returns the multiplication of two signed integers, reverting on
|
||||
* overflow.
|
||||
*
|
||||
* Counterpart to Solidity's `*` operator.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - Multiplication cannot overflow.
|
||||
*/
|
||||
function mul(int256 a, int256 b) internal pure returns (int256) {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the integer division of two signed integers. Reverts on
|
||||
* division by zero. The result is rounded towards zero.
|
||||
*
|
||||
* Counterpart to Solidity's `/` operator.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - The divisor cannot be zero.
|
||||
*/
|
||||
function div(int256 a, int256 b) internal pure returns (int256) {
|
||||
return a / b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the subtraction of two signed integers, reverting on
|
||||
* overflow.
|
||||
*
|
||||
* Counterpart to Solidity's `-` operator.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - Subtraction cannot overflow.
|
||||
*/
|
||||
function sub(int256 a, int256 b) internal pure returns (int256) {
|
||||
return a - b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the addition of two signed integers, reverting on
|
||||
* overflow.
|
||||
*
|
||||
* Counterpart to Solidity's `+` operator.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - Addition cannot overflow.
|
||||
*/
|
||||
function add(int256 a, int256 b) internal pure returns (int256) {
|
||||
return a + b;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user