4 ms·
Note that approach done naively will produce wrong answers for lots of divisors, because the reciprocal will not be exactly representable. For example, 49*(1.0/
by ridiculous_fish 10y ago
Note that approach done naively will produce wrong answers for lots of divisors, because the reciprocal will not be exactly representable. For example, 49*(1.0/49) is less than one.
If you round the FP division up (to the next largest representable value, that is), it should be correct, for 32 bit integer types at least.