Daniel Lemire's blog

, 3 min read

How quickly can you convert floats to doubles (and back)?

5 thoughts on “How quickly can you convert floats to doubles (and back)?”

  1. Alexander says:

    Hello.
    Can you explain why you are creating a random number generator and don’t use it. But filling the array with increasing values?

    1. It is dead code that I used at first but that I am no longer using. You don’t need the random generator because the conversion is not data dependent.

  2. Joe Duarte says:

    Hi Daniel – Why is the latency 3-4 cycles if one conversion takes one cycle? What is latency here? You’re using 1 cycle/conversion in your throughput estimates, so is the latency a one-time thing?

    1. I did not write that the conversion took one cycle, I wrote that one number could be converted per cycle. Our processors are superscalar: they can execute many instructions at once.

      1. In fact, the M1 processor in my Apple laptop can sustain 8 instructions per cycle.