evil floating point bit level hacking
|
10-22-2015, 07:45 PM
Post: #1
|
|||
|
|||
evil floating point bit level hacking
There's this fast inverse square root method that is often used in 3D graphics programs to calculate a normalized vector:
Code: float Q_rsqrt( float number ) While it's not precisely known how the magic number 0x5f3759df was determined the idea of the algorithm appears already in a drafted paper by Prof W. Kahan and K.C. Ng, written in May, 1986: Quote:B. sqrt(x) by Reciproot Iteration-- sqrt implementation in fdlibm Since Kahan was the primary architect behind the IEEE 754-1985 standard for floating-point computation I wonder whether he already had that trick in mind when defining their representation: Though the HP-71B was the first handheld to implement the IEEE floating-point standard I doubt that this trick could be used. Since it was also HP's first calculator based on the Saturn processor the floating point numbers are BCD-formatted coded. But then the approximation \(\log(1+x)\approx x\) can't be used since \(x\) isn't \(\ll 1\). Cheers Thomas |
|||
10-22-2015, 09:29 PM
Post: #2
|
|||
|
|||
RE: evil floating point bit level hacking
As the "father of floating point," Kahan discovering this trick would not surprise me "one bit"
Graph 3D | QPI | SolveSys |
|||
06-09-2024, 03:06 PM
Post: #3
|
|||
|
|||
RE: evil floating point bit level hacking
I was digging into the fast inverse square again last night, and made the personal discovery that Kahan was connected to this.
The algorithm reminded me so much of the CORDIC algorithm, in that it is equal parts a mixture of maths and computer science hacking. And it ties in with the TVM stuff too, in that Kahan had a hand in improving the algorithm for the HP-27 and later, and also that Newton's method is used for the fast inverse square and often used to solve for i. |
|||
06-09-2024, 05:18 PM
Post: #4
|
|||
|
|||
RE: evil floating point bit level hacking
.
Kahan!!! |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)