author | sheepluva |
Sun, 01 Mar 2015 17:12:02 +0100 | |
changeset 10842 | a039464cbb4a |
parent 8047 | 25a4daa6473c |
child 14190 | 801dc57371c3 |
permissions | -rw-r--r-- |
7983 | 1 |
#include "pmath.h" |
8047
25a4daa6473c
cleanup headers, remove -I . from rtl lib to save a few warnings
koda
parents:
7983
diff
changeset
|
2 |
#include <stdlib.h> |
7983 | 3 |
#include <math.h> |
4 |
||
5 |
/* |
|
6 |
* power raises base to the power power. |
|
7 |
* This is equivalent to exp(power*ln(base)). Therefore base should be non-negative. |
|
8 |
*/ |
|
9 |
float fpcrtl_power(float base, float exponent) |
|
10 |
{ |
|
11 |
return exp(exponent * log(base)); |
|
12 |
} |
|
13 |
||
14 |
/* Currently the games only uses sign of an integer */ |
|
15 |
int fpcrtl_signi(int x) |
|
16 |
{ |
|
17 |
if(x > 0){ |
|
18 |
return 1; |
|
19 |
} |
|
20 |
else if(x < 0){ |
|
21 |
return -1; |
|
22 |
} |
|
23 |
else{ |
|
24 |
return 0; |
|
25 |
} |
|
26 |
} |
|
27 |
||
28 |
float fpcrtl_csc(float x) |
|
29 |
{ |
|
30 |
return 1 / sin(x); |
|
31 |
} |
|
32 |
||
33 |
float __attribute__((overloadable)) fpcrtl_abs(float x) |
|
34 |
{ |
|
35 |
return fabs(x); |
|
36 |
} |
|
37 |
double __attribute__((overloadable)) fpcrtl_abs(double x) |
|
38 |
{ |
|
39 |
return fabs(x); |
|
40 |
} |
|
41 |
int __attribute__((overloadable)) fpcrtl_abs(int x) |
|
42 |
{ |
|
43 |
return abs(x); |
|
44 |
} |
|
45 |
||
46 |
int64_t __attribute__((overloadable)) fpcrtl_abs(int64_t x) |
|
47 |
{ |
|
48 |
return x < 0 ? -x : x; |
|
49 |
} |