Re:How do compilers optimize divisions?
by SamReidHughes on Thursday February 23, 2017 @01:43AM
(#13712117)
That only works when the value is known to be a multiple of whatever you're dividing by, and they do use that when it is the case, such as for pointer subtraction.
19 * 678,152,731 = 1 (mod 2^32)
19 * 9,708,812,670,373,448,219 = 1 (mod 2^64)
As long as we already know the size of an int Euclid's algorithm should be able to find these inverses if they exist.