commited some changes and added README
[meinos.git] / apps / include / math.h
blob30d1dff5d4c4d234c332f2ebd87923014843c242
1 /*
2 meinOS - A unix-like x86 microkernel operating system
3 Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef _MATH_H_
20 #define _MATH_H_
22 # define M_E 2.7182818284590452354 /* e */
23 # define M_LOG2E 1.4426950408889634074 /* log_2 e */
24 # define M_LOG10E 0.43429448190325182765 /* log_10 e */
25 # define M_LN2 0.69314718055994530942 /* log_e 2 */
26 # define M_LN10 2.30258509299404568402 /* log_e 10 */
27 # define M_PI 3.14159265358979323846 /* pi */
28 # define M_PI_2 1.57079632679489661923 /* pi/2 */
29 # define M_PI_4 0.78539816339744830962 /* pi/4 */
30 # define M_1_PI 0.31830988618379067154 /* 1/pi */
31 # define M_2_PI 0.63661977236758134308 /* 2/pi */
32 # define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
33 # define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
34 # define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
36 #define FLT_EVAL_METHOD 0
38 #define MAXFLOAT ((float)3.40282346638528860e+38)
39 #define HUGE MAXFLOAT
40 #define HUGE_VAL (__builtin_huge_val())
41 #define HUGE_VALF (__builtin_huge_valf())
42 #define HUGE_VALL (__builtin_huge_vall())
43 #define NAN (__builtin_nanf(""))
45 # define FP_NAN 1
46 # define FP_INFINITE 2
47 # define FP_ZERO 3
48 # define FP_SUBNORMAL 4
49 # define FP_NORMAL 5
51 #define X_TLOSS 1.41484755040568800000e+16
53 // Types of exceptions in the `type' field.
54 #define DOMAIN 1
55 #define SING 2
56 #define OVERFLOW 3
57 #define UNDERFLOW 4
58 #define TLOSS 5
59 #define PLOSS 6
61 #define fpclassify(x) (sizeof(x)==sizeof(float)?__fpclassifyf(x):(sizeof(x)==sizeof(double)?__fpclassify(x):__fpclassifyl(x)))
62 #define isfinite(x) (sizeof(x)==sizeof(float)?__isfinitef(x):(sizeof(x)==sizeof(double)?__isfinite(x):__isfinitel(x)))
63 #define isinf(x) (sizeof(x)==sizeof(float)?__isinff(x):(sizeof(x)==sizeof(double)?__isinf(x):__isinfl(x)))
64 #define isnan(x) (sizeof(x)==sizeof(float)?__isnanf(x):(sizeof(x)==sizeof(double)?__isnan(x):__isnanl(x)))
65 #define isnormal(x) (sizeof(x)==sizeof(float)?__isnormalf(x):(sizeof(x)==sizeof(double)?__isnormal(x):__isnormall(x)))
66 #define signbit(x) (sizeof(x)==sizeof(float)?__signbitf(x):(sizeof(x)==sizeof(double)?__signbit(x):__signbitl(x)))
68 #define isgreater(x, y) __builtin_isgreater(x, y)
69 #define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
70 #define isless(x, y) __builtin_isless(x, y)
71 #define islessequal(x, y) __builtin_islessequal(x, y)
72 #define islessgreater(x, y) __builtin_islessgreater(x, y)
73 #define isunordered(u, v) __builtin_isunordered(u, v)
75 typedef double double_t;
76 typedef float float_t;
78 # ifdef __cplusplus
79 struct __exception
80 # else
81 struct exception
82 # endif
84 int type;
85 char *name;
86 double arg1;
87 double arg2;
88 double retval;
91 # ifdef __cplusplus
92 extern int matherr(struct __exception *__exc) throw ();
93 # else
94 extern int matherr(struct exception *__exc);
95 # endif
97 int __isfinite(double x);
98 int __isnan(double x);
99 int __isinf(double x);
101 int __isfinitef(float x);
102 int __isnanf(float x);
103 int __isinff(float x);
105 #endif /* _MATH_H_ */