AnsweredAssumed Answered

Which is faster: floating point division or casting to 64-bit int?

Question asked by Andy Berger on Aug 17, 2018
Latest reply on Aug 21, 2018 by Erich Styger

Consider the simple calculation:

 

result = (A/B)*scaleFactor

 

where all quantities are unsigned, 32-bit integers.

 

 

A/B is strictly less than 1, but 

A*scaleFactor could be larger than 2^32.

 

Therefore, it seems I have two options:

result = ((float)(A)/B)*scaleFactor

or

result = ((uint64_t)(A)*scaleFactor)/B

 

Which sequence of operations is faster on the K64?

Outcomes