this operation uint256 pow2 = d & -d
is from FullMath.sol
function fullDiv(
uint256 l,
uint256 h,
uint256 d
) private pure returns (uint256) {
uint256 pow2 = d & -d;
d /= pow2;
.....
}
I tested this operation with 20 and -20.
00010100 = 20
11101100 = -20
its bitwise and result is (If I am not mistaken so far)
00010100 & 11101100=00000100
Why is this significant? Uniswap named variable AS pow2
but all the numbers from binary are already the power of 2. After the bitwise operation, d
is divided by pow2pow2=d & -d
Its bitwise operation. I am trying to understand, what is the point of this division.