aboutsummaryrefslogtreecommitdiffstats
path: root/code/game/q_math.c
diff options
context:
space:
mode:
Diffstat (limited to 'code/game/q_math.c')
-rwxr-xr-xcode/game/q_math.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/code/game/q_math.c b/code/game/q_math.c
index bb0faf6..53412e1 100755
--- a/code/game/q_math.c
+++ b/code/game/q_math.c
@@ -551,15 +551,17 @@ void VectorRotate( vec3_t in, vec3_t matrix[3], vec3_t out )
*/
float Q_rsqrt( float number )
{
- long i;
+ union {
+ float f;
+ int i;
+ } t;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
- y = number;
- i = * ( long * ) &y; // evil floating point bit level hacking
- i = 0x5f3759df - ( i >> 1 ); // what the fuck?
- y = * ( float * ) &i;
+ t.f = number;
+ t.i = 0x5f3759df - ( t.i >> 1 ); // what the fuck?
+ y = t.f;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed