Imported Upstream version 2.9.0
[debian/cc1111] / device / include / pic / math.h
1 /*-------------------------------------------------------------------------
2    math.h: Floating point math function declarations
3
4     Ported to PIC16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr)
5     Adopted for the PIC14 port 2006 by Raphael Neider <rneider AT web.de>
6     
7     Copyright (C) 2001  Jesus Calvino-Fraga, jesusc@ieee.org 
8
9     This library is free software; you can redistribute it and/or
10     modify it under the terms of the GNU Lesser General Public
11     License as published by the Free Software Foundation; either
12     version 2.1 of the License, or (at your option) any later version.
13
14     This library is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17     Lesser General Public License for more details.
18
19     You should have received a copy of the GNU Lesser General Public
20     License along with this library; if not, write to the Free Software
21     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22 -------------------------------------------------------------------------*/
23
24 /*
25 ** $Id: math.h 4776 2007-04-29 13:15:51Z borutr $
26 */
27
28
29 #ifndef __PIC14_MATH_H
30 #define __PIC14_MATH_H  1
31
32 #include <sdcc-lib.h>
33
34 #define PI          3.1415926536
35 #define TWO_PI      6.2831853071
36 #define HALF_PI     1.5707963268
37 #define QUART_PI    0.7853981634
38 #define iPI         0.3183098862
39 #define iTWO_PI     0.1591549431
40 #define TWO_O_PI    0.6366197724
41
42 // EPS=B**(-t/2), where B is the radix of the floating-point representation
43 // and there are t base-B digits in the significand.  Therefore, for floats
44 // EPS=2**(-12).  Also define EPS2=EPS*EPS.
45 #define EPS 244.14062E-6
46 #define EPS2 59.6046E-9
47 #define XMAX 3.402823466E+38
48
49 union float_long
50 {
51     float f;
52     long l;
53 };
54
55 /**********************************************
56  * Prototypes for float ANSI C math functions *
57  **********************************************/
58
59 /* Trigonometric functions */
60 float sinf(const float x) _MATH_REENTRANT;
61 float cosf(const float x) _MATH_REENTRANT;
62 float tanf(const float x) _MATH_REENTRANT;
63 float cotf(const float x) _MATH_REENTRANT;
64 float asinf(const float x) _MATH_REENTRANT;
65 float acosf(const float x) _MATH_REENTRANT;
66 float atanf(const float x) _MATH_REENTRANT;
67 float atan2f(const float x, const float y);
68
69 /* Hyperbolic functions */
70 float sinhf(const float x) _MATH_REENTRANT;
71 float coshf(const float x) _MATH_REENTRANT;
72 float tanhf(const float x) _MATH_REENTRANT;
73
74 /* Exponential, logarithmic and power functions */
75 float expf(const float x);
76 float logf(const float x) _MATH_REENTRANT;
77 float log10f(const float x) _MATH_REENTRANT;
78 float powf(const float x, const float y);
79 float sqrtf(const float a) _MATH_REENTRANT;
80
81 /* Nearest integer, absolute value, and remainder functions */
82 float fabsf(const float x) _MATH_REENTRANT;
83 float frexpf(const float x, int *pw2);
84 float ldexpf(const float x, const int pw2);
85 float ceilf(float x) _MATH_REENTRANT;
86 float floorf(float x) _MATH_REENTRANT;
87 float modff(float x, float * y);
88
89 #endif  /* __PIC14_MATH_H */