home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / INC.PAK / MATH.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  11KB  |  328 lines

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