The fast inverse square root is based on the fact that the integer representation of a floating point number is a rough approximation of its logarithm.
So convert floating point to its integer representation. So now you have its approximate logarithm. Now take half of that and improve that with some Newton raphson.
Comments
Tl;DR :
The fast inverse square root is based on the fact that the integer representation of a floating point number is a rough approximation of its logarithm.
So convert floating point to its integer representation. So now you have its approximate logarithm. Now take half of that and improve that with some Newton raphson.
So convert floating point to its integer representation.
Would something dirty like this be feasible in rust?
AFAICT transmute would work: http://rustbyexample.com/staging/unsafe.html
That's what's great about Rust, you can write unsafe code when you need it and it's isolated in `unsafe` blocks for easy auditing.
EDIT: Didn't test it too much, but looks like it works.
EDIT2: Shorter, more readable version.It would be exact if we used a logarithm based number system: http://en.wikipedia.org/wiki/Logarithmic_number_system
This kind of system is beautiful, but there is no easy way to add and subtract.