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