Loading [MathJax]/extensions/MathMenu.js
Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
fake_tgmath.h
Go to the documentation of this file.
1#pragma cplusplus on
2
3extern inline float sqrtf(float x) {
4 static const double _half=.5;
5 static const double _three=3.0;
6 volatile float y;
7 if(x > 0.0f) {
8 double guess = __frsqrte((double)x); // returns an approximation to
9 guess = _half*guess*(_three - guess*guess*x); // now have 12 sig bits
10 guess = _half*guess*(_three - guess*guess*x); // now have 24 sig bits
11 guess = _half*guess*(_three - guess*guess*x); // now have 32 sig bits
12 y=(float)(x*guess);
13 return y ;
14 }
15 return x ;
16}
17
18extern inline float sqrt(float x) {
19 static const double _half=.5;
20 static const double _three=3.0;
21 volatile float y;
22 if(x > 0.0f) {
23 double guess = __frsqrte((double)x); // returns an approximation to
24 guess = _half*guess*(_three - guess*guess*x); // now have 12 sig bits
25 guess = _half*guess*(_three - guess*guess*x); // now have 24 sig bits
26 guess = _half*guess*(_three - guess*guess*x); // now have 32 sig bits
27 guess = _half*guess*(_three - guess*guess*x); // now have 32 sig bits
28
29 y=(float)(x*guess);
30 return y ;
31 }
32 return x ;
33}
34
35extern inline float fabs(float x) {
36#if __MIPS__
37 return fabsf(x);
38#else
39 (*(int*)&x)&=0x7fffffff;
40 return x;
41#endif
42}
43
44extern inline float fabsf(float x) {
45 return __fabsf(x);
46}
47
48extern float cosf(float);
49extern inline float cos(float x) {
50 return cosf(x);
51}
52
53inline float floor(float x) {
54 int i=(int)x;
55 float y=x-(float)i;
56
57 if(!y || x > 8388608.0f)
58 return x ; // x is already an int
59
60 if(x < 0)
61 return (float)--i;
62 // x < 0 -> int conversion of x above rounded toward zero(so decrement)
63 return (float)i;
64}
65
66#pragma cplusplus reset
void floor()
double x double x
Definition e_atan2.c:58
double x double y
Definition e_atan2.c:58
int i
Definition e_pow.c:165
float cosf(float)
Definition d_kankyo.cpp:26
float fabs(float x)
Definition fake_tgmath.h:35
float sqrtf(float x)
Definition fake_tgmath.h:3
float sqrt(float x)
Definition fake_tgmath.h:18
float cos(float x)
Definition fake_tgmath.h:49
float fabsf(float x)
Definition fake_tgmath.h:44
float __fabsf(float)
double __frsqrte(double)