Closed code423n4 closed 2 years ago
0x0x0x
It costs less gas to shift than division. So rather than dividing by a power of 2, right shift can be used to save gas.
./libraries/MathLib.sol:43: return ((a * WAD) + (b / 2)) / b; ./libraries/MathLib.sol:55: return ((a + (n / 2)) / n) * n; ./libraries/MathLib.sol:67: return ((a * b) + (WAD / 2)) / WAD; ./libraries/MathLib.sol:85: uint256 x = y / 2 + 1; ./libraries/MathLib.sol:88: x = (y / x + x) / 2;
dupe of #100
Handle
0x0x0x
Vulnerability details
It costs less gas to shift than division. So rather than dividing by a power of 2, right shift can be used to save gas.
Occurrences