SSBM Decomp
Toggle main menu visibility
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
#include <
MetroTRK/intrinsics.h
>
5
6
#ifdef __MWERKS__
7
#pragma push
8
#pragma cplusplus on
9
#endif
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
static
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
intrinsics.h
sqrtf
float sqrtf(float x)
Definition
math_ppc.h:11
sqrtf_accurate
#define sqrtf_accurate(x)
Definition
placeholder.h:15
__frsqrte
#define __frsqrte(x)
Definition
placeholder.h:13
src
MSL
math_ppc.h
Generated by
1.17.0