feat(libraries): add fixed-point and low-level math primitives
This commit is contained in:
1 parent
3f335c47ec
commit
d83d3c1e96
4 files changed
+48
No files matched your search
@@ -0,0 +1,11 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.36;
|
||||
|
||||
/// @title Rounding-up integer division that trusts its non-zero denominator.
|
||||
library UnsafeMath {
|
||||
function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
|
||||
assembly {
|
||||
z := add(div(x, y), gt(mod(x, y), 0))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user