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