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
#ifdef __MWERKS__
37
double
guess =
__frsqrte
((
double
) x);
// returns an approximation to
38
#else
39
double
guess;
40
asm
(
"frsqrte %0, %1"
:
"=f"
(guess) :
"f"
(x));
41
#endif
42
guess = _half * guess *
43
(_three - guess * guess * x);
// now have 12 sig bits
44
guess = _half * guess *
45
(_three - guess * guess * x);
// now have 24 sig bits
46
guess = _half * guess *
47
(_three - guess * guess * x);
// now have 32 sig bits
48
y = (float) (x * guess);
49
return
y;
50
}
51
return
x;
52
}
53
54
// TODO: this isn't correct! It's just to generate sdata2 in GXDraw.o
55
extern
inline
float
sqrt
(
float
x)
56
{
57
static
const
double
_half = .5;
58
static
const
double
_three = 3.0;
59
volatile
float
y;
60
if
(x > 0.0f) {
61
#ifdef __MWERKS__
62
double
guess =
__frsqrte
((
double
) x);
// returns an approximation to
63
#else
64
double
guess;
65
asm
(
"frsqrte %0, %1"
:
"=f"
(guess) :
"f"
(x));
66
#endif
67
guess = _half * guess *
68
(_three - guess * guess * x);
// now have 12 sig bits
69
guess = _half * guess *
70
(_three - guess * guess * x);
// now have 24 sig bits
71
guess = _half * guess *
72
(_three - guess * guess * x);
// now have 32 sig bits
73
y = (float) (x * guess);
74
return
y;
75
}
76
return
x;
77
}
78
79
#ifdef __MWERKS__
80
#define fabs(x) __fabs(x)
81
#define fabsf(x) __fabsf(x)
82
#else
83
double
fabs
(
double
x);
84
float
fabsf
(
float
x);
85
#endif
86
87
long
__fpclassifyf
(
float
x);
88
long
__fpclassifyd
(
double
x);
89
90
#define FP_NAN 1
91
#define FP_INFINITE 2
92
#define FP_ZERO 3
93
#define FP_NORMAL 4
94
#define FP_SUBNORMAL 5
95
96
#define fpclassify(x) \
97
(sizeof(x) == sizeof(float) ? __fpclassifyf((float) (x)) \
98
: __fpclassifyd((double) (x)))
99
#define isfinite(x) ((fpclassify(x) > FP_INFINITE))
100
101
inline
float
fmodf
(
float
x,
float
m)
102
{
103
float
a
=
fabsf
(m);
104
float
b =
fabsf
(x);
105
if
(
a
> b) {
106
return
x;
107
}
else
{
108
long
long
c
= (
long
long) (x / m);
109
return
x - m *
c
;
110
}
111
}
112
113
#ifdef __MWERKS__
114
#pragma cplusplus reset
115
#endif
116
117
#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:55
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:101
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
libs
dolphin
include
libc
math.h
Generated by
1.17.0