]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/common/mathlib.qh
add a crude version of <math.h> to QC
[divverent/nexuiz.git] / data / qcsrc / common / mathlib.qh
1 // <math.h>
2
3 #define int float
4
5 #define FP_NAN 0
6 #define FP_INFINITE 1
7 #define FP_ZERO 2
8 #define FP_SUBNORMAL 3
9 #define FP_NORMAL 4
10 int fpclassify(float x);
11 int isfinite(float x);
12 int isinf(float x);
13 int isnan(float x);
14 int isnormal(float x);
15 int signbit(float x);
16
17 //float acos(float x);
18 //float asin(float x);
19 //float atan(float x);
20 //float atan2(float y, float x);
21 //float cos(float x);
22 //float sin(float x);
23 //float tan(float x);
24
25 float acosh(float x);
26 float asinh(float x);
27 float atanh(float x);
28 float cosh(float x);
29 float sinh(float x);
30 float tanh(float x);
31
32 float exp(float x);
33 float exp2(float x);
34 float expm1(float x);
35
36 vector frexp(float x); // returns mantissa as _x, exponent as _y
37 int ilogb(float x);
38 float ldexp(float x, int e);
39 float log(float x);
40 float log10(float x);
41 float log1p(float x);
42 float log2(float x);
43 float logb(float x);
44 vector modf(float f); // fraction as _x, integer as _y
45
46 float scalbn(float x, int n);
47
48 float cbrt(float x);
49 //float fabs(float x);
50 float hypot(float x, float y);
51 //float pow(float x, float y);
52 //float sqrt(float x, float y);
53
54 float erf(float x);
55 float erfc(float x);
56 vector lgamma(float x); // value in _x, sign in _y
57 float tgamma(float x);
58
59 //float ceil(float x);
60 //float floor(float x);
61 float nearbyint(float x);
62 //float rint(float x);
63 //float round(float x);
64 float trunc(float x);
65
66 float fmod(float x, float y);
67 float remainder(float x, float y);
68 vector remquo(float x, float y);
69
70 float copysign(float x, float y);
71 float nan(string tag);
72 float nextafter(float x, float y);
73 float nexttoward(float x, float y);
74
75 float fdim(float x, float y);
76 float fmax(float x, float y);
77 float fmin(float x, float y);
78 float fma(float x, float y, float z);
79
80 int isgreater(float x, float y);
81 int isgreaterequal(float x, float y);
82 int isless(float x, float y);
83 int islessequal(float x, float y);
84 int islessgreater(float x, float y);
85 int isunordered(float x, float y);
86
87 #define M_E        2.7182818284590452354   /* e */
88 #define M_LOG2E    1.4426950408889634074   /* log_2 e */
89 #define M_LOG10E   0.43429448190325182765  /* log_10 e */
90 #define M_LN2      0.69314718055994530942  /* log_e 2 */
91 #define M_LN10     2.30258509299404568402  /* log_e 10 */
92 #define M_PI       3.14159265358979323846  /* pi */
93 #define M_PI_2     1.57079632679489661923  /* pi/2 */
94 #define M_PI_4     0.78539816339744830962  /* pi/4 */
95 #define M_1_PI     0.31830988618379067154  /* 1/pi */
96 #define M_2_PI     0.63661977236758134308  /* 2/pi */
97 #define M_2_SQRTPI 1.12837916709551257390  /* 2/sqrt(pi) */
98 #define M_SQRT2    1.41421356237309504880  /* sqrt(2) */
99 #define M_SQRT1_2  0.70710678118654752440  /* 1/sqrt(2) */