mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
18 lines
660 B
Solidity
18 lines
660 B
Solidity
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
pragma solidity >=0.5.0;
|
|
|
|
/// @title Math functions that do not check inputs or outputs
|
|
/// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks
|
|
library UnsafeMath {
|
|
/// @notice Returns ceil(x / y)
|
|
/// @dev division by 0 has unspecified behavior, and must be checked externally
|
|
/// @param x The dividend
|
|
/// @param y The divisor
|
|
/// @return z The quotient, ceil(x / y)
|
|
function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
|
|
assembly {
|
|
z := add(div(x, y), gt(mod(x, y), 0))
|
|
}
|
|
}
|
|
}
|