From 448f04aff1e2b96287f37755ef1b12d9339ea135 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 3 Jun 2007 14:19:43 +0000 Subject: Fixed warning about strict-aliasing rules and don't die on warnings by default. --- src/utils/fastsqrt.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/utils') diff --git a/src/utils/fastsqrt.h b/src/utils/fastsqrt.h index 8ba6f8ce..8da1d354 100644 --- a/src/utils/fastsqrt.h +++ b/src/utils/fastsqrt.h @@ -9,15 +9,16 @@ float fastInvSqrt(float x) { - float xhalf = 0.5f*x; - int i = *(int*)&x; - i = 0x5f375a86- (i>>1); - x = *(float*)&i; - x = x*(1.5f-xhalf*x*x); + union { int i; float x; } tmp; + float xhalf = 0.5f * x; + tmp.x = x; + tmp.i = 0x5f375a86 - (tmp.i >> 1); + x = tmp.x; + x = x * (1.5f - xhalf * x * x); return x; } float fastSqrt(float x) { - return 1.0f/fastInvSqrt(x); + return 1.0f / fastInvSqrt(x); } -- cgit v1.2.3-70-g09d2