Move abs(int256) from Math to SafeMath (#3110)

Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
(cherry picked from commit 3eb2d43b06)
Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
Hadrien Croubois
2022-01-14 23:27:04 +01:00
parent a8a08bef58
commit fdfd9726e1
7 changed files with 32 additions and 32 deletions

View File

@ -40,14 +40,4 @@ library Math {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a / b + (a % b == 0 ? 0 : 1);
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}