From 1ef32d13abd2c0b080b230b81007d560fbe50b55 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 13 Apr 2013 21:49:03 +0200 Subject: [PATCH] Custom implementations of isnan/isinf as it's just a mess portability-wise.. --- math/math_util.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/math/math_util.h b/math/math_util.h index d5c7e0a14c..bea22b291a 100644 --- a/math/math_util.h +++ b/math/math_util.h @@ -4,6 +4,8 @@ #include #include +#include "base/basictypes.h" + inline float sqr(float f) {return f*f;} inline float sqr_signed(float f) {return f<0 ? -f*f : f*f;} @@ -73,6 +75,24 @@ inline float dB2lin(float dB) { return expf(dB * DB_2_LOG); } +inline bool my_isinf(float f) { + union { + float f; + uint32_t u; + } f2u; + f2u.f = f; + return f2u.u == 0x7f800000 || + f2u.u == 0xff800000; +} + +inline bool my_isnan(float f) { + union { + float f; + uint32_t u; + } f2u; + f2u.f = f; + return (f2u.u & 0x7F800000) == 0x7F800000; +} // FPU control. void EnableFZ();