326ab00e620a90845f57f54acf60cd1e7603c999
[fw/sdcc] / device / include / math.h
1 /*  math.h: Floating point math function declarations
2
3     Copyright (C) 2001  Jesus Calvino-Fraga, jesusc@ieee.org 
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Lesser General Public
7     License as published by the Free Software Foundation; either
8     version 2.1 of the License, or (at your option) any later version.
9
10     This library 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 GNU
13     Lesser General Public License for more details.
14
15     You should have received a copy of the GNU Lesser General Public
16     License along with this library; if not, write to the Free Software
17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA */
18
19 /* Version 1.0 - Initial release */
20
21 #ifndef _INC_MATH
22 #define _INC_MATH
23
24 #define PI          3.1415926536
25 #define TWO_PI      6.2831853071
26 #define HALF_PI     1.5707963268
27 #define QUART_PI    0.7853981634
28 #define iPI         0.3183098862
29 #define iTWO_PI     0.1591549431
30 #define TWO_O_PI    0.6366197724
31
32 // EPS=B**(-t/2), where B is the radix of the floating-point representation
33 // and there are t base-B digits in the significand.  Therefore, for floats
34 // EPS=2**(-12).  Also define EPS2=EPS*EPS.
35 #define EPS 244.14062E-6
36 #define EPS2 59.6046E-9
37 #define XMAX 3.402823466E+38
38
39 union float_long
40 {
41     float f;
42     long l;
43 };
44
45 /**********************************************
46  * Prototypes for float ANSI C math functions *
47  **********************************************/
48
49 /* Trigonometric functions */
50 float sinf(const float x);
51 float cosf(const float x);
52 float tanf(const float x);
53 float cotf(const float x);
54 float asinf(const float x);
55 float acosf(const float x);
56 float atanf(const float x);
57 float atan2f(const float x, const float y);
58
59 /* Hyperbolic functions */
60 float sinhf(const float x);
61 float coshf(const float x);
62 float tanhf(const float x);
63
64 /* Exponential, logarithmic and power functions */
65 float expf(const float x);
66 float logf(const float x);
67 float log10f(const float x);
68 float powf(const float x, const float y);
69 float sqrtf(const float a);
70
71 /* Nearest integer, absolute value, and remainder functions */
72 float fabsf(const float x);
73 float frexpf(const float x, int *pw2);
74 float ldexpf(const float x, const int pw2);
75 float ceilf(float x);
76 float floorf(float x);
77 float modff(float x, float * y);
78
79 #endif  /* _INC_MATH */