15 #define SIGN_BITMASK 0x80000000 18 #define IR(x) ((udword&)(x)) 21 #define SIR(x) ((sdword&)(x)) 24 #define AIR(x) (IR(x)&0x7fffffff) 27 #define FR(x) ((float&)(x)) 32 #define IS_NEGATIVE_FLOAT(x) ((x)<0) 45 #if defined(_MSC_VER) && not defined(_WIN64) 74 (
float&)y = (
float&)y * ( 1.5f - ( x * (
float&)y * (
float&)
y ) );
83 float y = *(
float*)&tmp;
84 return y * (1.47f - 0.47f * x * y *
y);
93 const float threehalfs = 1.5f;
98 i = 0x5f3759df - (i >> 1);
100 y = y * (threehalfs - (x2 * y *
y));
108 udword y = ( ( (
sdword&)f - 0x3f800000 ) >> 1 ) + 0x3f800000;
120 (
float&)a -= (
float&)
b;
133 if(
IsNAN(value))
return false;
140 #define CHECK_VALID_FLOAT(x) ASSERT(IsValidFloat(x)); 183 return x*x < epsilon;
186 #define FCOMI_ST0 _asm _emit 0xdb _asm _emit 0xf0 187 #define FCOMIP_ST0 _asm _emit 0xdf _asm _emit 0xf0 188 #define FCMOVB_ST0 _asm _emit 0xda _asm _emit 0xc0 189 #define FCMOVNB_ST0 _asm _emit 0xdb _asm _emit 0xc0 191 #define FCOMI_ST1 _asm _emit 0xdb _asm _emit 0xf1 192 #define FCOMIP_ST1 _asm _emit 0xdf _asm _emit 0xf1 193 #define FCMOVB_ST1 _asm _emit 0xda _asm _emit 0xc1 194 #define FCMOVNB_ST1 _asm _emit 0xdb _asm _emit 0xc1 196 #define FCOMI_ST2 _asm _emit 0xdb _asm _emit 0xf2 197 #define FCOMIP_ST2 _asm _emit 0xdf _asm _emit 0xf2 198 #define FCMOVB_ST2 _asm _emit 0xda _asm _emit 0xc2 199 #define FCMOVNB_ST2 _asm _emit 0xdb _asm _emit 0xc2 201 #define FCOMI_ST3 _asm _emit 0xdb _asm _emit 0xf3 202 #define FCOMIP_ST3 _asm _emit 0xdf _asm _emit 0xf3 203 #define FCMOVB_ST3 _asm _emit 0xda _asm _emit 0xc3 204 #define FCMOVNB_ST3 _asm _emit 0xdb _asm _emit 0xc3 206 #define FCOMI_ST4 _asm _emit 0xdb _asm _emit 0xf4 207 #define FCOMIP_ST4 _asm _emit 0xdf _asm _emit 0xf4 208 #define FCMOVB_ST4 _asm _emit 0xda _asm _emit 0xc4 209 #define FCMOVNB_ST4 _asm _emit 0xdb _asm _emit 0xc4 211 #define FCOMI_ST5 _asm _emit 0xdb _asm _emit 0xf5 212 #define FCOMIP_ST5 _asm _emit 0xdf _asm _emit 0xf5 213 #define FCMOVB_ST5 _asm _emit 0xda _asm _emit 0xc5 214 #define FCMOVNB_ST5 _asm _emit 0xdb _asm _emit 0xc5 216 #define FCOMI_ST6 _asm _emit 0xdb _asm _emit 0xf6 217 #define FCOMIP_ST6 _asm _emit 0xdf _asm _emit 0xf6 218 #define FCMOVB_ST6 _asm _emit 0xda _asm _emit 0xc6 219 #define FCMOVNB_ST6 _asm _emit 0xdb _asm _emit 0xc6 221 #define FCOMI_ST7 _asm _emit 0xdb _asm _emit 0xf7 222 #define FCOMIP_ST7 _asm _emit 0xdf _asm _emit 0xf7 223 #define FCMOVB_ST7 _asm _emit 0xda _asm _emit 0xc7 224 #define FCMOVNB_ST7 _asm _emit 0xdb _asm _emit 0xc7 229 #if defined(_MSC_VER) && not defined(_WIN64) 239 return (a > b) ? a :
b;
246 #if defined(_MSC_VER) && not defined(_WIN64) 256 return (a < b) ? a :
b;
263 #if defined(_MSC_VER) && not defined(_WIN64) 276 return (a > b) ? ((a >
c) ? a : c) : ((b >
c) ? b : c);
283 #if defined(_MSC_VER) && not defined(_WIN64) 296 return (a < b) ? ((a <
c) ? a : c) : ((b <
c) ? b : c);
303 int Fmask = (Fi>>31);
338 #endif // __ICEFPU_H__
FUNCTION ICECORE_API void SetFPURoundingDown()
#define IR(x)
Integer representation of a floating-point value.
FUNCTION ICECORE_API void SetFPURoundingNear()
FUNCTION ICECORE_API void RestoreFPU()
inline_ float FCMin2(float a, float b)
A global function to find MIN(a,b) using FCOMI/FCMOV.
inline_ float frsqrt(float f)
Computes 1.0f / sqrtf(x).
signed int sdword
sizeof(sdword) must be 4
FUNCTION ICECORE_API int intChop(const float &f)
inline_ float FastSqrt(float square)
Fast square root for floating-point values.
FUNCTION ICECORE_API void SetFPUPrecision64()
#define FR(x)
Floating-point representation of an integer value.
inline_ float fepsilon(float f)
Returns the float ranged espilon value.
FUNCTION ICECORE_API void SetFPUFloorMode()
FUNCTION ICECORE_API void SetFPUCeilMode()
inline_ bool IsMinusInf(float value)
inline_ float RSqrt(float number)
FUNCTION ICECORE_API void SetFPUPrecision24()
unsigned int udword
sizeof(udword) must be 4
FUNCTION ICECORE_API int intCeil(const float &f)
FUNCTION ICECORE_API int intFloor(const float &f)
inline_ bool IsNAN(float value)
Is the float valid ?
FUNCTION ICECORE_API FPUMode GetFPUMode()
FUNCTION ICECORE_API void SetFPURoundingChop()
inline_ bool IsFloatZero(float x, float epsilon=1e-6f)
inline_ int ConvertToSortable(float f)
inline_ bool IsValidFloat(float value)
inline_ float fsqrt(float f)
TO BE DOCUMENTED.
inline_ float fsat(float f)
Saturates positive to zero.
FUNCTION ICECORE_API void SaveFPU()
inline_ float InvSqrt(const float &x)
Computes 1.0f / sqrtf(x). Comes from NVIDIA.
inline_ float FCMin3(float a, float b, float c)
A global function to find MIN(a,b,c) using FCOMI/FCMOV.
inline_ bool IsIndeterminate(float value)
inline_ float FCMax3(float a, float b, float c)
A global function to find MAX(a,b,c) using FCOMI/FCMOV.
#define IEEE_1_0
integer representation of 1.0
FUNCTION ICECORE_API void SetFPUBestMode()
inline_ bool IsPlusInf(float value)
inline_ float ComputeFloatEpsilon()
This function computes the slowest possible floating-point value (you can also directly use FLT_EPSIL...
inline_ float FastFabs(float x)
FUNCTION ICECORE_API void SetFPURoundingUp()
inline_ float FCMax2(float a, float b)
A global function to find MAX(a,b) using FCOMI/FCMOV.
FUNCTION ICECORE_API void SetFPUPrecision53()