From 9e3a7cd6dd02b12f880d9e9e220bfdadc09417e1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 28 Apr 2003 15:24:17 +0000 Subject: [PATCH] LOG2() clean-up (Klaus Niederkrueger) --- src/mesa/main/imports.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 5a42cfaf8b5..e16e95cb0b8 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -198,14 +198,14 @@ static INLINE GLfloat LOG2(GLfloat x) */ static INLINE GLfloat LOG2(GLfloat val) { - GLint *exp_ptr = (GLint *) &val; - GLint x = *exp_ptr; - const GLint log_2 = ((x >> 23) & 255) - 128; - x &= ~(255 << 23); - x += 127 << 23; - *exp_ptr = x; - val = ((-1.0f/3) * val + 2) * val - 2.0f/3; - return val + log_2; + fi_type num; + GLint log_2; + num.f = val; + log_2 = ((num.i >> 23) & 255) - 128; + num.i &= ~(255 << 23); + num.i += 127 << 23; + num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3; + return num.f + log_2; } #elif defined(XFree86LOADER) && defined(IN_MODULE) #define LOG2(x) ((GLfloat) (xf86log(x) * 1.442695)) -- 2.30.2