4 ms·
I'll just leave this here: https://en.wikipedia.org/wiki/Fast_inverse_square_root https://en.wikipedia.org/wiki/Fast_inverse_square_root
by gpderetta 3y ago
I'll just leave this here: https://en.wikipedia.org/wiki/Fast_inverse_square_root https://en.wikipedia.org/wiki/Fast_inverse_square_root
- CyberDildonics 3y agoThey said sane reason and that most programmers would never need to do it. I don't think the magic inverse square root contradicts that.
- pif 3y agoI stand corrected: there is one very good reason to want to treat a float like an integer. But if you can come up with such a solution, you are definitely not one to stop at their first guess, and you'll double-check the standard before the final commit.
- gpderetta 3y agoOk, what about: https://leonardschuetz.ch/blog/nan-boxing/ https://leonardschuetz.ch/blog/nan-boxing/
- 0xf00ff00f 3y agoAnother use is doing radix sort of floating point numbers. Since the exponent is in the most significant bits you can almost treat them as integers for radix sort (you just need to be a bit careful with negative values): http://www.codercorner.com/RadixSortRevisited.htm http://www.codercorner.com/RadixSortRevisited.htm