summaryrefslogtreecommitdiff
path: root/src/qcommon/q_math.c
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2009-10-03 12:31:59 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:16:03 +0000
commit304d4258d3a49488f570b8ad71931faa7e5d40ba (patch)
treebf9ec15bd9154305ff9fab2943b3daf25024f8a5 /src/qcommon/q_math.c
parent6e90e4e7861f5cb354487d1fe0f1fd06c385308e (diff)
* Merge ioq3-r1498, by popular demand
Diffstat (limited to 'src/qcommon/q_math.c')
-rw-r--r--src/qcommon/q_math.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/qcommon/q_math.c b/src/qcommon/q_math.c
index a3a7b191..e7924073 100644
--- a/src/qcommon/q_math.c
+++ b/src/qcommon/q_math.c
@@ -550,10 +550,7 @@ void VectorRotate( vec3_t in, vec3_t matrix[3], vec3_t out )
*/
float Q_rsqrt( float number )
{
- union {
- float f;
- int i;
- } t;
+ floatint_t t;
float x2, y;
const float threehalfs = 1.5F;
@@ -568,9 +565,10 @@ float Q_rsqrt( float number )
}
float Q_fabs( float f ) {
- int tmp = * ( int * ) &f;
- tmp &= 0x7FFFFFFF;
- return * ( float * ) &tmp;
+ floatint_t fi;
+ fi.f = f;
+ fi.i &= 0x7FFFFFFF;
+ return fi.f;
}
#endif
@@ -1587,15 +1585,11 @@ Don't pass doubles to this
*/
int Q_isnan( float x )
{
- union
- {
- float f;
- unsigned int i;
- } t;
+ floatint_t fi;
- t.f = x;
- t.i &= 0x7FFFFFFF;
- t.i = 0x7F800000 - t.i;
+ fi.f = x;
+ fi.ui &= 0x7FFFFFFF;
+ fi.ui = 0x7F800000 - fi.ui;
- return (int)( (unsigned int)t.i >> 31 );
+ return (int)( (unsigned int)fi.ui >> 31 );
}