From f0d9497e1f31cddbb60d00b34ef72e26faf86bd9 Mon Sep 17 00:00:00 2001 From: castano Date: Wed, 28 Sep 2011 19:54:05 +0000 Subject: [PATCH] Add missing changes. --- src/nvmath/nvmath.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/nvmath/nvmath.h b/src/nvmath/nvmath.h index aa28a84..d3ef217 100644 --- a/src/nvmath/nvmath.h +++ b/src/nvmath/nvmath.h @@ -251,6 +251,29 @@ namespace nv return floor(saturate(f) * scale + offset) / scale; }*/ + union Float754 { + unsigned int raw; + float value; + struct { + #if NV_BIG_ENDIAN + unsigned int negative:1; + unsigned int biasedexponent:8; + unsigned int mantissa:23; + #else + unsigned int mantissa:23; + unsigned int biasedexponent:8; + unsigned int negative:1; + #endif + } field; + }; + + // Return the exponent of x ~ Floor(Log2(x)) + inline int floatExponent(float x) + { + Float754 f; + f.value = x; + return (f.field.biasedexponent - 127); + } } // nv #endif // NV_MATH_H