author | Wuzzy <Wuzzy2@mail.ru> |
Wed, 09 Jan 2019 19:39:48 +0100 | |
changeset 14530 | ec0afe1c6024 |
parent 14197 | 3e551b0535fb |
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 |
/* Currently the games only uses sign of an integer */ |
|
6 |
int fpcrtl_signi(int x) |
|
7 |
{ |
|
8 |
if(x > 0){ |
|
9 |
return 1; |
|
10 |
} |
|
11 |
else if(x < 0){ |
|
12 |
return -1; |
|
13 |
} |
|
14 |
else{ |
|
15 |
return 0; |
|
16 |
} |
|
17 |
} |
|
18 |
||
19 |
float fpcrtl_csc(float x) |
|
20 |
{ |
|
21 |
return 1 / sin(x); |
|
22 |
} |
|
23 |
||
24 |
float __attribute__((overloadable)) fpcrtl_abs(float x) |
|
25 |
{ |
|
14185
801dc57371c3
Pas2C: Fix bad C typedefs for Pascal data types Extended and Real
Wuzzy <Wuzzy2@mail.ru>
parents:
8047
diff
changeset
|
26 |
return fabsf(x); |
7983 | 27 |
} |
28 |
double __attribute__((overloadable)) fpcrtl_abs(double x) |
|
29 |
{ |
|
30 |
return fabs(x); |
|
31 |
} |
|
14185
801dc57371c3
Pas2C: Fix bad C typedefs for Pascal data types Extended and Real
Wuzzy <Wuzzy2@mail.ru>
parents:
8047
diff
changeset
|
32 |
long double __attribute__((overloadable)) fpcrtl_abs(long double x) |
801dc57371c3
Pas2C: Fix bad C typedefs for Pascal data types Extended and Real
Wuzzy <Wuzzy2@mail.ru>
parents:
8047
diff
changeset
|
33 |
{ |
801dc57371c3
Pas2C: Fix bad C typedefs for Pascal data types Extended and Real
Wuzzy <Wuzzy2@mail.ru>
parents:
8047
diff
changeset
|
34 |
return fabsl(x); |
801dc57371c3
Pas2C: Fix bad C typedefs for Pascal data types Extended and Real
Wuzzy <Wuzzy2@mail.ru>
parents:
8047
diff
changeset
|
35 |
} |
7983 | 36 |
int __attribute__((overloadable)) fpcrtl_abs(int x) |
37 |
{ |
|
38 |
return abs(x); |
|
39 |
} |
|
40 |
||
41 |
int64_t __attribute__((overloadable)) fpcrtl_abs(int64_t x) |
|
42 |
{ |
|
43 |
return x < 0 ? -x : x; |
|
44 |
} |