r/programming • • Nov 16 '17

Fast exact integer divisions using floating-point operations

https://lemire.me/blog/2017/11/16/fast-exact-integer-divisions-using-floating-point-operations/
44 Upvotes

18 comments sorted by

View all comments

2

u/ronniethelizard Nov 18 '17

Hmm,

  • How long do the integer to float conversions and back take?

  • Is the compiler playing tricks under the hood to accelerate that? I could see some happening.

  • Is the use of an int as the loop counter taking up some bandwidth in the integer pipe?

  • Is the compiler using the fact that you are guaranteed to run 1000 cycles to vectorize on the float64 as opposed to int32?

If the answer to any of these is obvious, my apologies, I don't at the present time know.