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