include/crbn/basic/fastmath.h

00001 
00002 #ifndef __fast_math_h__
00003 #define __fast_math_h__
00004 
00005 #define __FASTMATH_EPSILON__ 2
00006 
00007 #define fm_eps_eq( x, y ) (abs( (*(unsigned*)(&x)) - (*(unsigned*)(&y)) ) < __FASTMATH_EPSILON__)
00008 
00009 inline int fm_neg( float f )
00010 {
00011 /*   return ((*(unsigned*)(&f)) & 0x80000000); */
00012   union {
00013     float f;
00014     unsigned int u;
00015   } conv;
00016   conv.f = f;
00017   return conv.u & 0x80000000;
00018 }
00019 
00020 inline float fm_abs( float f )
00021 {
00022 /*   unsigned u = (*(unsigned*)&f) & 0x7FFFFFFF; */
00023 /*   return (*(float*)&u); */
00024   union {
00025     float f;
00026     unsigned int u;
00027   } conv;
00028  
00029   conv.f = f;
00030   conv.u &= 0x7FFFFFFF;
00031   return conv.f;  
00032 }
00033 
00034 #undef __FASTMATH_EPSILON__
00035 
00036 #endif // __fast_math_h__

Generated on Tue Nov 14 15:40:08 2006 for libcrbn by  doxygen 1.5.0