home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / GNU_1OF3.ZIP / HEADERS.ZIP / g++-include / math.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-06  |  4.9 KB  |  215 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of the GNU C++ Library.  This library is free
  7. software; you can redistribute it and/or modify it under the terms of
  8. the GNU Library General Public License as published by the Free
  9. Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.  This library is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  12. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE.  See the GNU Library General Public License for more details.
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19.  
  20. #ifndef _math_h
  21. #ifdef __GNUG__
  22. #pragma interface
  23. #endif
  24. #define _math_h 1
  25.  
  26. #if defined(hp300) && defined(__HAVE_FPU__)
  27. #define __HAVE_68881__ 1
  28. #endif
  29.  
  30. #if defined(masscomp)
  31. #define __HAVE_68881__ 1
  32. #endif
  33.  
  34. #ifdef __HAVE_68881__        /* MC68881/2 Floating-Point Coprocessor */
  35. extern "C" {            /* fill in what we've left out */
  36. #include <math-68881.h>
  37.  
  38. double  acosh(double);
  39. double  asinh(double);
  40. double  cbrt(double);
  41. double  copysign(double,double);
  42. double  erf(double);
  43. double  erfc(double);
  44. double  finite(double);
  45. double  gamma(double);
  46. double  hypot(double,double);
  47. double  infnan(int);
  48. int     isinf(double);
  49. int     isnan(double);
  50. double  j0(double);
  51. double  j1(double);
  52. double  jn(int, double);
  53. double  lgamma(double);
  54. double  y0(double);
  55. double  y1(double);
  56. double  yn(int, double);
  57.  
  58. double aint(double);
  59. double anint(double);
  60. int irint(double);
  61. int nint(double);
  62. }
  63. /* Please add inline asm code for other machines here! */
  64. #else
  65. extern "C" {
  66.  
  67. double  acos(double);
  68. double  acosh(double);
  69. double  asin(double);
  70. double  asinh(double);
  71. double  atan(double);
  72. double  atan2(double, double);
  73. double  atanh(double);
  74. double  cbrt(double);
  75. double  ceil(double);
  76. double  copysign(double,double);
  77. double  cos(double);
  78. double  cosh(double);
  79. double  drem(double,double);
  80. double  erf(double);
  81. double  erfc(double);
  82. double  exp(double);
  83. double  expm1(double);
  84. double  fabs(double);
  85. double  finite(double);
  86. double  floor(double);
  87. double  frexp(double, int*);
  88. double  gamma(double);
  89. double  hypot(double,double);
  90. double  infnan(int);
  91. #if !defined(sequent) && !defined(DGUX) &&!defined(sony) && !defined(masscomp) && !defined(hpux)
  92. /* see below */
  93. int     isinf(double);
  94. int     isnan(double);
  95. #endif
  96. double  j0(double);
  97. double  j1(double);
  98. double  jn(int, double);
  99. double  ldexp(double, int);
  100. double  lgamma(double);
  101. double  log(double);
  102. double  log10(double);
  103. double  log1p(double);
  104. double  logb(double);
  105. double  modf(double, double*);
  106. double  pow(double, double);
  107. double  rint(double);
  108. double  scalb(double, int);
  109. double  sin(double);
  110. double  sinh(double);
  111. double  sqrt(double);
  112. double  tan(double);
  113. double  tanh(double);
  114. double  y0(double);
  115. double  y1(double);
  116. double  yn(int, double);
  117.  
  118. double aint(double);
  119. double anint(double);
  120. int irint(double);
  121. int nint(double);
  122. }
  123.  
  124. #endif
  125.  
  126. /* libg++ doesn't use this since it is not available on some systems */
  127.  
  128. /* the following ifdef is just for compiling OOPS */
  129.  
  130. #ifndef DONT_DECLARE_EXCEPTION
  131. struct libm_exception
  132. {
  133.   int type;
  134.   char* name;
  135.   double arg1, arg2, retval;
  136. };
  137.  
  138. #define DOMAIN      1
  139. #define SING        2
  140. #define OVERFLOW    3
  141. #define UNDERFLOW   4
  142. #define TLOSS       5
  143. #define PLOSS       6
  144.  
  145. extern "C" int matherr(libm_exception*);
  146.  
  147. #endif
  148.  
  149. #include <values.h>
  150.  
  151. /* On some systems, HUGE ought to be MAXFLOAT or IEEE infinity */
  152.  
  153. #ifndef HUGE
  154. #define HUGE    MAXDOUBLE
  155. #endif
  156.  
  157.  
  158. /* sequents don't supply these. The following should suffice */
  159. #if defined(sequent) || defined(DGUX) || defined(sony) || defined(masscomp) \
  160. || defined(hpux)
  161. static inline int isnan(double x) { return x != x; }
  162. static inline int isinf(double x) { return x > MAXDOUBLE || x < -MAXDOUBLE; }
  163. #endif
  164.  
  165. /* These seem to be sun & sysV names of these constants */
  166.  
  167. #ifndef M_E
  168. #define M_E         2.7182818284590452354
  169. #endif
  170. #ifndef M_LOG2E
  171. #define M_LOG2E     1.4426950408889634074
  172. #endif
  173. #ifndef M_LOG10E
  174. #define M_LOG10E    0.43429448190325182765
  175. #endif
  176. #ifndef M_LN2
  177. #define M_LN2       0.69314718055994530942
  178. #endif
  179. #ifndef M_LN10
  180. #define M_LN10      2.30258509299404568402
  181. #endif
  182. #ifndef M_PI
  183. #define M_PI        3.14159265358979323846
  184. #endif
  185. #ifndef M_PI_2
  186. #define M_PI_2      1.57079632679489661923
  187. #endif
  188. #ifndef M_1_PI
  189. #define M_1_PI      0.31830988618379067154
  190. #endif
  191. #ifndef M_PI_4
  192. #define M_PI_4      0.78539816339744830962
  193. #endif
  194. #ifndef M_2_PI
  195. #define M_2_PI      0.63661977236758134308
  196. #endif
  197. #ifndef M_2_SQRTPI
  198. #define M_2_SQRTPI  1.12837916709551257390
  199. #endif
  200. #ifndef M_SQRT2
  201. #define M_SQRT2     1.41421356237309504880
  202. #endif
  203. #ifndef M_SQRT1_2
  204. #define M_SQRT1_2   0.70710678118654752440
  205. #endif
  206.  
  207. #ifndef PI                      // as in stroustrup
  208. #define PI  M_PI
  209. #endif
  210. #ifndef PI2
  211. #define PI2  M_PI_2
  212. #endif
  213.  
  214. #endif
  215.