SSBM Decomp
Toggle main menu visibility
Loading...
Searching...
No Matches
math.h
Go to the documentation of this file.
1
#ifndef _MATH_H_
2
#define _MATH_H_
3
4
#define NAN (0.0f / 0.0f)
5
#define HUGE_VALF (1.0f / 0.0f)
6
#define INFINITY (1.0f / 0.0f)
7
8
double
fabs
(
double
x);
9
double
sin
(
double
x);
10
double
cos
(
double
x);
11
12
float
sinf
(
float
x);
13
float
cosf
(
float
x);
14
float
tanf
(
float
x);
15
float
acosf
(
float
x);
16
float
powf
(
float
base,
float
exponent);
17
18
double
ldexp
(
double
x,
int
exp);
19
20
double
scalbn
(
double
x,
int
n);
21
22
double
copysign
(
double
x,
double
y);
23
24
#ifdef __MWERKS__
25
#pragma cplusplus on
26
#endif
27
28
double
floor
(
double
x);
29
30
extern
inline
float
sqrtf
(
float
x)
31
{
32
static
const
double
_half = .5;
33
static
const
double
_three = 3.0;
34
volatile
float
y;
35
if
(x > 0.0f)
36
{
37
#ifdef __MWERKS__
38
double
guess =
__frsqrte
((
double
)x);
// returns an approximation to
39
#else
40
double
guess;
41
asm
(
"frsqrte %0, %1"
:
"=f"
(guess) :
"f"
(x));
42
#endif
43
guess = _half*guess*(_three - guess*guess*x);
// now have 12 sig bits
44
guess = _half*guess*(_three - guess*guess*x);
// now have 24 sig bits
45
guess = _half*guess*(_three - guess*guess*x);
// now have 32 sig bits
46
y = (float)(x*guess);
47
return
y ;
48
}
49
return
x;
50
}
51
52
// TODO: this isn't correct! It's just to generate sdata2 in GXDraw.o
53
extern
inline
float
sqrt
(
float
x)
54
{
55
static
const
double
_half = .5;
56
static
const
double
_three = 3.0;
57
volatile
float
y;
58
if
(x > 0.0f)
59
{
60
#ifdef __MWERKS__
61
double
guess =
__frsqrte
((
double
)x);
// returns an approximation to
62
#else
63
double
guess;
64
asm
(
"frsqrte %0, %1"
:
"=f"
(guess) :
"f"
(x));
65
#endif
66
guess = _half*guess*(_three - guess*guess*x);
// now have 12 sig bits
67
guess = _half*guess*(_three - guess*guess*x);
// now have 24 sig bits
68
guess = _half*guess*(_three - guess*guess*x);
// now have 32 sig bits
69
y = (float)(x*guess);
70
return
y ;
71
}
72
return
x;
73
}
74
75
#ifdef __MWERKS__
76
#define fabs(x) __fabs(x)
77
#define fabsf(x) __fabsf(x)
78
#else
79
double
fabs
(
double
x);
80
float
fabsf
(
float
x);
81
#endif
82
83
long
__fpclassifyf
(
float
x);
84
long
__fpclassifyd
(
double
x);
85
86
#define FP_NAN 1
87
#define FP_INFINITE 2
88
#define FP_ZERO 3
89
#define FP_NORMAL 4
90
#define FP_SUBNORMAL 5
91
92
#define fpclassify(x) (sizeof(x) == sizeof(float) ? __fpclassifyf((float)(x)) : __fpclassifyd((double)(x)))
93
#define isfinite(x) ((fpclassify(x) > FP_INFINITE))
94
95
inline
float
fmodf
(
float
x,
float
m)
96
{
97
float
a
=
fabsf
(m);
98
float
b =
fabsf
(x);
99
if
(
a
> b)
100
return
x;
101
else
102
{
103
long
long
c
= (
long
long)(x / m);
104
return
x - m *
c
;
105
}
106
}
107
108
#ifdef __MWERKS__
109
#pragma cplusplus reset
110
#endif
111
112
#endif
scalbn
double scalbn(double x, int n)
sqrtf
float sqrtf(float x)
Definition
math.h:30
sqrt
float sqrt(float x)
Definition
math.h:53
cos
double cos(double x)
tanf
float tanf(float x)
Definition
trigf.c:126
floor
double floor(double x)
cosf
float cosf(float x)
Definition
trigf.c:68
__fpclassifyd
long __fpclassifyd(double x)
sinf
float sinf(float x)
Definition
trigf.c:24
fmodf
float fmodf(float x, float m)
Definition
math.h:95
fabs
double fabs(double x)
acosf
float acosf(float x)
Definition
lbtrigf.c:45
fabsf
float fabsf(float x)
__fpclassifyf
long __fpclassifyf(float x)
sin
double sin(double x)
ldexp
double ldexp(double x, int exp)
copysign
double copysign(double x, double y)
powf
float powf(float base, float exponent)
Definition
lb_00CE.c:63
__frsqrte
#define __frsqrte(x)
Definition
placeholder.h:13
c
int c
Definition
tev.c:10
a
GXColorS10 a
Definition
tev.c:9
extern
dolphin
include
libc
math.h
Generated by
1.17.0