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 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)