Skip to main content
Clarify that it isn't a simplification.
Source Link
Ismael
  • 30.3k
  • 23
  • 54
  • 97

What is the importance of d /= pow2

The calculation uint256 pow2 = d & -d is the greatest power of 2 that divides d.

With d /= pow2 it is removing the zeros to the right. It is the equivalent of simplifying a division: 50"shifting" to the right both numerator and denominator. For example 51 / 20 = 5 (51 / 2, but using powers of 2 instead of powers of 104) / (20 / 4) = 12.75 / 5.

It is an optimization.

What is the importance of d /= pow2

The calculation uint256 pow2 = d & -d is the greatest power of 2 that divides d.

With d /= pow2 it is removing the zeros to the right. It is the equivalent of simplifying a division: 50 / 20 = 5 / 2, but using powers of 2 instead of powers of 10.

It is an optimization.

What is the importance of d /= pow2

The calculation uint256 pow2 = d & -d is the greatest power of 2 that divides d.

With d /= pow2 it is removing the zeros to the right. It is the "shifting" to the right both numerator and denominator. For example 51 / 20 = (51 / 4) / (20 / 4) = 12.75 / 5.

It is an optimization.

Source Link
Ismael
  • 30.3k
  • 23
  • 54
  • 97

What is the importance of d /= pow2

The calculation uint256 pow2 = d & -d is the greatest power of 2 that divides d.

With d /= pow2 it is removing the zeros to the right. It is the equivalent of simplifying a division: 50 / 20 = 5 / 2, but using powers of 2 instead of powers of 10.

It is an optimization.