Skip to content

Commit

Permalink
Add comment on 0/0 division of divup
Browse files Browse the repository at this point in the history
  • Loading branch information
sunbreak1211 committed Oct 10, 2023
1 parent 4928ce0 commit 7ba968f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/AllocatorVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ contract AllocatorVault {
// --- math ---

function _divup(uint256 x, uint256 y) internal pure returns (uint256 z) {
// Note: _divup(0,0) will return 0 differing from natural solidity division
unchecked {
z = x != 0 ? ((x - 1) / y) + 1 : 0;
}
Expand Down
1 change: 1 addition & 0 deletions test/AllocatorVault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ contract AllocatorVaultTest is DssTest {
event Wipe(address indexed sender, uint256 wad);

function _divup(uint256 x, uint256 y) internal pure returns (uint256 z) {
// Note: _divup(0,0) will return 0 differing from natural solidity division
unchecked {
z = x != 0 ? ((x - 1) / y) + 1 : 0;
}
Expand Down

0 comments on commit 7ba968f

Please sign in to comment.