SSBM Decomp
Loading...
Searching...
No Matches
math_ppc.h
Go to the documentation of this file.
1
#ifndef _MATH_PPC_H_
2
#define _MATH_PPC_H_
// IWYU pragma: always_keep
3
4
#ifdef __MWERKS__
5
#pragma push
6
#pragma cplusplus on
7
#endif
8
9
extern
double
__frsqrte
(
double
);
10
11
extern
inline
float
sqrtf
(
float
x)
12
{
13
volatile
float
y;
14
if
(x > 0.0f) {
15
double
guess =
__frsqrte
((
double
) x);
// returns an approximation to
16
guess =
17
0.5 * guess * (3.0 - guess * guess * x);
// now have 12 sig bits
18
guess =
19
0.5 * guess * (3.0 - guess * guess * x);
// now have 24 sig bits
20
guess =
21
0.5 * guess * (3.0 - guess * guess * x);
// now have 32 sig bits
22
y = (float) (x * guess);
23
return
y;
24
}
25
return
x;
26
}
27
28
#ifdef __MWERKS__
29
#pragma pop
30
#endif
31
32
inline
float
sqrtf_accurate
(
float
x)
33
{
34
volatile
float
y;
35
if
(x > 0.0f) {
36
double
guess =
__frsqrte
((
double
) x);
// returns an approximation to
37
guess =
38
0.5 * guess * (3.0 - guess * guess * x);
// now have 12 sig bits
39
guess =
40
0.5 * guess * (3.0 - guess * guess * x);
// now have 24 sig bits
41
guess =
42
0.5 * guess * (3.0 - guess * guess * x);
// now have 32 sig bits
43
guess = 0.5 * guess * (3.0 - guess * guess * x);
// extra iteration
44
y = (float) (x * guess);
45
return
y;
46
}
47
return
x;
48
}
49
50
#endif
sqrtf
float sqrtf(float x)
Definition
math_ppc.h:11
__frsqrte
double __frsqrte(double)
sqrtf_accurate
float sqrtf_accurate(float x)
Definition
math_ppc.h:32
src
MSL
math_ppc.h
Generated by
1.15.0