Re:How do compilers optimize divisions?
by ridiculous_fish on Tuesday February 21, 2017 @03:52AM
(#13694266)
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.
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.