math.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*-------------------------------------------------------------------------
  2. math.h - Floating point math function declarations
  3. Copyright (C) 2001, Jesus Calvino-Fraga <jesusc AT ieee.org>
  4. Ported to PIC16 port by Vangelis Rokas, 2004 <vrokas AT otenet.gr>
  5. This library is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU General Public License as published by the
  7. Free Software Foundation; either version 2, or (at your option) any
  8. later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this library; see the file COPYING. If not, write to the
  15. Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  16. MA 02110-1301, USA.
  17. As a special exception, if you link this library with other files,
  18. some of which are compiled with SDCC, to produce an executable,
  19. this library does not by itself cause the resulting executable to
  20. be covered by the GNU General Public License. This exception does
  21. not however invalidate any other reasons why the executable file
  22. might be covered by the GNU General Public License.
  23. -------------------------------------------------------------------------*/
  24. #ifndef __PIC16_MATH_H
  25. #define __PIC16_MATH_H 1
  26. #pragma library math
  27. #include <sdcc-lib.h>
  28. #define PI 3.1415926536
  29. #define TWO_PI 6.2831853071
  30. #define HALF_PI 1.5707963268
  31. #define QUART_PI 0.7853981634
  32. #define iPI 0.3183098862
  33. #define iTWO_PI 0.1591549431
  34. #define TWO_O_PI 0.6366197724
  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. union float_long
  42. {
  43. float f;
  44. long l;
  45. };
  46. /**********************************************
  47. * Prototypes for float ANSI C math functions *
  48. **********************************************/
  49. /* Trigonometric functions */
  50. float sinf(const float x) _MATH_REENTRANT;
  51. float cosf(const float x) _MATH_REENTRANT;
  52. float tanf(const float x) _MATH_REENTRANT;
  53. float cotf(const float x) _MATH_REENTRANT;
  54. float asinf(const float x) _MATH_REENTRANT;
  55. float acosf(const float x) _MATH_REENTRANT;
  56. float atanf(const float x) _MATH_REENTRANT;
  57. float atan2f(const float x, const float y);
  58. /* Hyperbolic functions */
  59. float sinhf(const float x) _MATH_REENTRANT;
  60. float coshf(const float x) _MATH_REENTRANT;
  61. float tanhf(const float x) _MATH_REENTRANT;
  62. /* Exponential, logarithmic and power functions */
  63. float expf(const float x);
  64. float logf(const float x) _MATH_REENTRANT;
  65. float log10f(const float x) _MATH_REENTRANT;
  66. float powf(const float x, const float y);
  67. float sqrtf(const float a) _MATH_REENTRANT;
  68. /* Nearest integer, absolute value, and remainder functions */
  69. float fabsf(const float x) _MATH_REENTRANT;
  70. float frexpf(const float x, int *pw2);
  71. float ldexpf(const float x, const int pw2);
  72. float ceilf(float x) _MATH_REENTRANT;
  73. float floorf(float x) _MATH_REENTRANT;
  74. float modff(float x, float * y);
  75. #endif /* _PIC16_MATH_H */