Change behavior of ceilDiv(0, 0) and improve test coverage (#4348)
This commit is contained in:
@ -114,6 +114,11 @@ library Math {
|
||||
* of rounding down.
|
||||
*/
|
||||
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
if (b == 0) {
|
||||
// Guarantee the same behavior as in a regular Solidity division.
|
||||
return a / b;
|
||||
}
|
||||
|
||||
// (a + b - 1) / b can overflow on addition, so we distribute.
|
||||
return a == 0 ? 0 : (a - 1) / b + 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user