home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / INC.PAK / MATH.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  11.9 KB  |  345 lines

  1.  
  2. /*  math.h
  3.  
  4.     Definitions for the math floating point package.
  5.  
  6. */
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 8.0
  10.  *
  11.  *      Copyright (c) 1987, 1997 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15. /* $Revision:   8.10  $ */
  16.  
  17. #ifndef  __MATH_H
  18. #define  __MATH_H
  19.  
  20. #if !defined(___DEFS_H)
  21. #include <_defs.h>
  22. #endif
  23.  
  24. #if !defined(__STDDEF_H)
  25. #include <stddef.h>
  26. #endif
  27.  
  28. #if !defined(RC_INVOKED)
  29.  
  30. #if defined(__STDC__)
  31. #pragma warn -nak
  32. #endif
  33.  
  34. #pragma pack(push, 1)
  35.  
  36. #endif  /* !RC_INVOKED */
  37.  
  38.  
  39. #if !defined(__STDC__) /* NON-ANSI */
  40.  
  41. #ifdef __cplusplus
  42.     /* use class complex instead of _cabs in C++ */
  43. #else
  44. struct complex      /* as used by "_cabs" function */
  45. {
  46.     double  x, y;
  47. };
  48.  
  49. struct _complexl    /* as used by "_cabsl" function */
  50. {
  51.     long double  x, y;
  52. };
  53.  
  54. #define cabs(z)     (hypot  ((z).x, (z).y))
  55. #define cabsl(z)    (hypotl ((z).x, (z).y))
  56. #endif /* NON-ANSI */
  57.  
  58. #endif
  59.  
  60. typedef enum
  61. {
  62.     DOMAIN = 1,    /* argument domain error -- log (-1)        */
  63.     SING,          /* argument singularity  -- pow (0,-2))     */
  64.     OVERFLOW,      /* overflow range error  -- exp (1000)      */
  65.     UNDERFLOW,     /* underflow range error -- exp (-1000)     */
  66.     TLOSS,         /* total loss of significance -- sin(10e70) */
  67.     PLOSS,         /* partial loss of signif. -- not used      */
  68.     STACKFAULT     /* floating point unit stack overflow       */
  69. }   _mexcep;
  70.  
  71. /* Constants rounded for 21 decimals. */
  72. #define M_E         2.71828182845904523536
  73. #define M_LOG2E     1.44269504088896340736
  74. #define M_LOG10E    0.434294481903251827651
  75. #define M_LN2       0.693147180559945309417
  76. #define M_LN10      2.30258509299404568402
  77. #define M_PI        3.14159265358979323846
  78. #define M_PI_2      1.57079632679489661923
  79. #define M_PI_4      0.785398163397448309616
  80. #define M_1_PI      0.318309886183790671538
  81. #define M_2_PI      0.636619772367581343076
  82. #define M_1_SQRTPI  0.564189583547756286948
  83. #define M_2_SQRTPI  1.12837916709551257390
  84. #define M_SQRT2     1.41421356237309504880
  85. #define M_SQRT_2    0.707106781186547524401
  86.  
  87. #define EDOM    33      /* Math argument */
  88. #define ERANGE  34      /* Result too large */
  89.  
  90. struct  exception
  91. {
  92.     int type;
  93.     char   _FAR *name;
  94.     double  arg1, arg2, retval;
  95. };
  96.  
  97. struct  _exceptionl
  98. {
  99.     int type;
  100.     char   _FAR *name;
  101.     long double  arg1, arg2, retval;
  102. };
  103.  
  104. #if !defined(__FLAT__)
  105.  
  106. #define HUGE_VAL    _huge_dble
  107. extern double _RTLENTRY _huge_dble;
  108. #define _LHUGE_VAL   _huge_ldble
  109. extern long double _RTLENTRY _huge_ldble;
  110.  
  111. #ifdef __cplusplus
  112. extern "C" {
  113. #endif
  114. double      _RTLENTRY _EXPFUNC acos    (double __x);
  115. double      _RTLENTRY _EXPFUNC asin    (double __x);
  116. double      _RTLENTRY          atan    (double __x);
  117. double      _RTLENTRY _EXPFUNC atan2   (double __y, double __x);
  118. double      _RTLENTRY _EXPFUNC ceil    (double __x);
  119. double      _RTLENTRY _EXPFUNC cos     (double __x);
  120. double      _RTLENTRY _EXPFUNC cosh    (double __x);
  121. double      _RTLENTRY _EXPFUNC exp     (double __x);
  122. double      _RTLENTRY          fabs    (double __x);
  123. double      _RTLENTRY          __fabs__(double __x); /* Intrinsic */
  124. double      _RTLENTRY _EXPFUNC floor   (double __x);
  125. double      _RTLENTRY _EXPFUNC fmod    (double __x, double __y);
  126. double      _RTLENTRY _EXPFUNC frexp   (double __x, int _FAR *__exponent);
  127. double      _RTLENTRY _EXPFUNC ldexp   (double __x, int __exponent);
  128. double      _RTLENTRY _EXPFUNC log     (double __x);
  129. double      _RTLENTRY _EXPFUNC log10   (double __x);
  130. double      _RTLENTRY _EXPFUNC modf    (double __x, double _FAR *__ipart);
  131. double      _RTLENTRY _EXPFUNC pow     (double __x, double __y);
  132. double      _RTLENTRY _EXPFUNC sin     (double __x);
  133. double      _RTLENTRY _EXPFUNC sinh    (double __x);
  134. double      _RTLENTRY _EXPFUNC sqrt    (double __x);
  135. double      _RTLENTRY _EXPFUNC tan     (double __x);
  136. double      _RTLENTRY _EXPFUNC tanh    (double __x);
  137.  
  138. long double _RTLENTRY _EXPFUNC acosl  (long double __x);
  139. long double _RTLENTRY _EXPFUNC asinl  (long double __x);
  140. long double _RTLENTRY _EXPFUNC atan2l (long double __x, long double __y);
  141. long double _RTLENTRY          atanl  (long double __x);
  142. long double _RTLENTRY _EXPFUNC ceill  (long double __x);
  143. long double _RTLENTRY _EXPFUNC coshl  (long double __x);
  144. long double _RTLENTRY _EXPFUNC cosl   (long double __x);
  145. long double _RTLENTRY _EXPFUNC expl   (long double __x);
  146. long double _RTLENTRY          fabsl  (long double __x);
  147. long double _RTLENTRY _EXPFUNC floorl (long double __x);
  148. long double _RTLENTRY _EXPFUNC fmodl  (long double __x, long double __y);
  149. long double _RTLENTRY _EXPFUNC frexpl (long double __x, int _FAR *__exponent);
  150. long double _RTLENTRY _EXPFUNC ldexpl (long double __x, int __exponent);
  151. long double _RTLENTRY _EXPFUNC log10l (long double __x);
  152. long double _RTLENTRY _EXPFUNC logl   (long double __x);
  153. long double _RTLENTRY _EXPFUNC modfl  (long double __x, long double _FAR *__ipart);
  154. long double _RTLENTRY _EXPFUNC powl   (long double __x, long double __y);
  155. long double _RTLENTRY _EXPFUNC sinhl  (long double __x);
  156. long double _RTLENTRY _EXPFUNC sinl   (long double __x);
  157. long double _RTLENTRY _EXPFUNC sqrtl  (long double __x);
  158. long double _RTLENTRY _EXPFUNC tanhl  (long double __x);
  159. long double _RTLENTRY _EXPFUNC tanl   (long double __x);
  160.  
  161. double      _RTLENTRY _EXPFUNC atof  (const char _FAR *__s);
  162.  
  163. #ifdef __cplusplus
  164. }
  165. #endif
  166.  
  167. #if !defined(__STDC__)
  168.  
  169. #ifdef __cplusplus
  170. extern "C" {
  171. #endif
  172.  
  173. double      _RTLENTRY _EXPFUNC hypot (double __x, double __y);
  174. int         _RTLENTRY _EXPFUNC _matherr (struct exception _FAR *__e);
  175. double      _RTLENTRY _EXPFUNC poly  (double __x, int __degree, double _FAR *__coeffs);
  176. double      _RTLENTRY _EXPFUNC pow10 (int __p);
  177. long double _RTLENTRY          hypotl (long double __x, long double __y);
  178. long double _RTLENTRY          polyl  (long double __x, int __degree, long double _FAR *__coeffs);
  179. long double _RTLENTRY _EXPFUNC pow10l (int __p);
  180.  
  181. #if !defined(__ABS_DEFINED)
  182. #define __ABS_DEFINED
  183. int         _RTLENTRY __abs__(int);
  184. #ifdef __cplusplus
  185. inline int _RTLENTRY  abs(int __x) { return __abs__(__x); }
  186. #else
  187. int         _RTLENTRY abs(int __x);
  188. #  define abs(x)   __abs__(x)
  189. #endif
  190.  
  191. #endif /* __ABS_DEFINED */
  192.  
  193. long        _RTLENTRY          labs  (long __x);
  194. int         _RTLENTRY _EXPFUNC _matherrl (struct _exceptionl _FAR *__e);
  195.  
  196. long double _RTLENTRY          hypotl (long double __x, long double __y);
  197. long double _RTLENTRY          polyl  (long double __x, int __degree, long double _FAR *__coeffs);
  198. long double _RTLENTRY _EXPFUNC pow10l (int __p);
  199.  
  200.  
  201. #ifdef __cplusplus
  202. }
  203. #endif
  204.  
  205. #endif  /* !__STDC__ */
  206.  
  207. #else   /* defined __FLAT__ */
  208.  
  209. #define HUGE_VAL    _huge_dble
  210. extern double _RTLENTRY _EXPDATA _huge_dble;
  211. #define _LHUGE_VAL   _huge_ldble
  212. extern long double _RTLENTRY _EXPDATA _huge_ldble;
  213.  
  214. #ifdef __cplusplus
  215. extern "C" {
  216. #endif
  217. double      _RTLENTRY _EXPFUNC acos    (double __x);
  218. double      _RTLENTRY _EXPFUNC asin    (double __x);
  219. double      _RTLENTRY _EXPFUNC atan    (double __x);
  220. double      _RTLENTRY _EXPFUNC atan2   (double __y, double __x);
  221. double      _RTLENTRY _EXPFUNC ceil    (double __x);
  222. double      _RTLENTRY _EXPFUNC cos     (double __x);
  223. double      _RTLENTRY _EXPFUNC cosh    (double __x);
  224. double      _RTLENTRY _EXPFUNC exp     (double __x);
  225. double      _RTLENTRY _EXPFUNC fabs    (double __x);
  226. double      _RTLENTRY _EXPFUNC floor   (double __x);
  227. double      _RTLENTRY _EXPFUNC fmod    (double __x, double __y);
  228. double      _RTLENTRY _EXPFUNC frexp   (double __x, int * __exponent);
  229. double      _RTLENTRY _EXPFUNC ldexp   (double __x, int __exponent);
  230. double      _RTLENTRY _EXPFUNC log     (double __x);
  231. double      _RTLENTRY _EXPFUNC log10   (double __x);
  232. double      _RTLENTRY _EXPFUNC modf    (double __x, double * __ipart);
  233. double      _RTLENTRY _EXPFUNC pow     (double __x, double __y);
  234. double      _RTLENTRY _EXPFUNC sin     (double __x);
  235. double      _RTLENTRY _EXPFUNC sinh    (double __x);
  236. double      _RTLENTRY _EXPFUNC sqrt    (double __x);
  237. double      _RTLENTRY _EXPFUNC tan     (double __x);
  238. double      _RTLENTRY _EXPFUNC tanh    (double __x);
  239.  
  240. long double _RTLENTRY _EXPFUNC acosl  (long double __x);
  241. long double _RTLENTRY _EXPFUNC asinl  (long double __x);
  242. long double _RTLENTRY _EXPFUNC atan2l (long double __x, long double __y);
  243. long double _RTLENTRY _EXPFUNC atanl  (long double __x);
  244. long double _RTLENTRY _EXPFUNC ceill  (long double __x);
  245. long double _RTLENTRY _EXPFUNC coshl  (long double __x);
  246. long double _RTLENTRY _EXPFUNC cosl   (long double __x);
  247. long double _RTLENTRY _EXPFUNC expl   (long double __x);
  248. long double _RTLENTRY _EXPFUNC fabsl  (long double __x);
  249. long double _RTLENTRY _EXPFUNC floorl (long double __x);
  250. long double _RTLENTRY _EXPFUNC fmodl  (long double __x, long double __y);
  251. long double _RTLENTRY _EXPFUNC frexpl (long double __x, int * __exponent);
  252. long double _RTLENTRY _EXPFUNC ldexpl (long double __x, int __exponent);
  253. long double _RTLENTRY _EXPFUNC log10l (long double __x);
  254. long double _RTLENTRY _EXPFUNC logl   (long double __x);
  255. long double _RTLENTRY _EXPFUNC modfl  (long double __x, long double * __ipart);
  256. long double _RTLENTRY _EXPFUNC powl   (long double __x, long double __y);
  257. long double _RTLENTRY _EXPFUNC sinhl  (long double __x);
  258. long double _RTLENTRY _EXPFUNC sinl   (long double __x);
  259. long double _RTLENTRY _EXPFUNC sqrtl  (long double __x);
  260. long double _RTLENTRY _EXPFUNC tanhl  (long double __x);
  261. long double _RTLENTRY _EXPFUNC tanl   (long double __x);
  262.  
  263. /* Intrinsic functions */
  264.  
  265. double      _RTLENTRY _EXPFUNC __sin__ (double __x);
  266. double      _RTLENTRY _EXPFUNC __cos__ (double __x);
  267. long double _RTLENTRY _EXPFUNC __cosl__(long double __x);
  268. long double _RTLENTRY _EXPFUNC __sinl__(long double __x);
  269.  
  270. double      _RTLENTRY _EXPFUNC atof    (const char * __s);
  271.  
  272. #ifdef __cplusplus
  273. }
  274. #endif
  275.  
  276. #if !defined(__STDC__) /* NON_ANSI */
  277.  
  278. #ifdef __cplusplus
  279. extern "C" {
  280. #endif
  281.  
  282. #if !defined(__ABS_DEFINED)
  283. #define __ABS_DEFINED
  284. int         _RTLENTRY __abs__(int);
  285. #ifdef __cplusplus
  286. inline int _RTLENTRY  abs(int __x) { return __abs__(__x); }
  287. #else
  288. int         _RTLENTRYF _EXPFUNC abs(int __x);
  289. #  define abs(x)   __abs__(x)
  290. #endif
  291. #endif /* __ABS_DEFINED */
  292.  
  293. long        _RTLENTRY _EXPFUNC labs    (long __x);
  294. double      _RTLENTRY _EXPFUNC pow10   (int __p);
  295.  
  296. long double _RTLENTRY _EXPFUNC _atold  (const char * __s);
  297.  
  298. int         _RTLENTRY          _matherr(struct exception  *__e);
  299. int         _RTLENTRY          _matherrl(struct _exceptionl *__e);
  300.  
  301. double      _RTLENTRY _EXPFUNC hypot   (double __x, double __y);
  302. double      _RTLENTRY _EXPFUNC poly    (double __x, int __degree, double coeffs []);
  303. long double _RTLENTRY _EXPFUNC hypotl  (long double __x, long double __y);
  304. long double _RTLENTRY _EXPFUNC polyl   (long double __x, int __degree, long double coeffs []);
  305. long double _RTLENTRY _EXPFUNC pow10l  (int __p);
  306.  
  307. #if (__BORLANDC__ >= 0x0520) && defined (_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS >= 64)
  308. __int64     _RTLENTRY _EXPFUNC   _atoi64(const char * __s);
  309. char *      _RTLENTRY   _EXPFUNC _i64toa(__int64 value, char *strP, int radix);
  310. char *      _RTLENTRY   _EXPFUNC _ui64toa(unsigned __int64 value, char *strP, int radix);
  311. __int64     _RTLENTRY _EXPFUNC   _wtoi64(const wchar_t * __s);
  312. wchar_t *   _RTLENTRY   _EXPFUNC _i64tow(__int64 value, wchar_t *strP, int radix);
  313. wchar_t *   _RTLENTRY   _EXPFUNC _ui64tow(unsigned __int64 value, wchar_t *strP, int radix);
  314. #endif
  315. double      _RTLENTRY _EXPFUNC   _wtof(const wchar_t * __s);
  316. int         _RTLENTRY _EXPFUNC   _wtoi(const wchar_t * __s);
  317. long        _RTLENTRY _EXPFUNC   _wtol(const wchar_t * __s);
  318. long double _RTLENTRY _EXPFUNC   _wtold(const wchar_t * __s);
  319.  
  320. #ifdef __cplusplus
  321. }
  322. #endif
  323.  
  324. #endif  /* !__STDC__ */
  325.  
  326. #endif  /* __FLAT__ */
  327.  
  328.  
  329. #if !defined(RC_INVOKED)
  330.  
  331. /* restore default packing */
  332. #pragma pack(pop)
  333.  
  334. #if defined(__STDC__)
  335. #pragma warn .nak
  336. #endif
  337.  
  338. #endif  /* !RC_INVOKED */
  339.  
  340.  
  341. #endif  /* __MATH_H */
  342.  
  343.  
  344.  
  345.