home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_11 / 2.ddi / INCLUDE.ZIP / MATH.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-13  |  3.7 KB  |  139 lines

  1. /*  math.h
  2.  
  3.     Definitions for the math floating point package.
  4.  
  5.     Copyright (c) Borland International 1987,1988,1990,1991
  6.     All Rights Reserved.
  7. */
  8.  
  9. #ifndef  __MATH_H
  10. #define  __MATH_H
  11.  
  12. #ifdef __DLL__
  13. #define _FAR far
  14. #else
  15. #define _FAR
  16. #endif
  17.  
  18. #if __STDC__
  19. #define _Cdecl
  20. #else
  21. #define _Cdecl  cdecl
  22. #endif
  23.  
  24. #ifndef __PAS__
  25. #define _CType _Cdecl
  26. #else
  27. #define _CType pascal
  28. #endif
  29.  
  30. #define HUGE_VAL    _huge_dble
  31. extern double _Cdecl _huge_dble;
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. double  _Cdecl acos  (double __x);
  37. double  _Cdecl asin  (double __x);
  38. double  _Cdecl atan  (double __x);
  39. double  _Cdecl atan2 (double __y, double __x);
  40. double  _Cdecl ceil  (double __x);
  41. double  _Cdecl cos   (double __x);
  42. double  _Cdecl cosh  (double __x);
  43. double  _Cdecl exp   (double __x);
  44. double  _Cdecl fabs  (double __x);
  45. double  _Cdecl floor (double __x);
  46. double  _Cdecl fmod  (double __x, double __y);
  47. double  _Cdecl frexp (double __x, int _FAR *__exponent);
  48. double  _Cdecl ldexp (double __x, int __exponent);
  49. double  _Cdecl log   (double __x);
  50. double  _Cdecl log10 (double __x);
  51. double  _Cdecl modf  (double __x, double _FAR *__ipart);
  52. double  _Cdecl pow   (double __x, double __y);
  53. double  _Cdecl sin   (double __x);
  54. double  _Cdecl sinh  (double __x);
  55. double  _Cdecl sqrt  (double __x);
  56. double  _Cdecl tan   (double __x);
  57. double  _Cdecl tanh  (double __x);
  58.  
  59. /*  The customary matherr() exception handler for math functions is
  60.     not compatible with the x3j11 draft standard for C.  _matherr() is
  61.     provided as a compromise.
  62. */
  63.  
  64. typedef enum
  65. {
  66.     DOMAIN = 1,    /* argument domain error -- log (-1)        */
  67.     SING,          /* argument singularity  -- pow (0,-2))     */
  68.     OVERFLOW,      /* overflow range error  -- exp (1000)      */
  69.     UNDERFLOW,     /* underflow range error -- exp (-1000)     */
  70.     TLOSS,         /* total loss of significance -- sin(10e70) */
  71.     PLOSS,         /* partial loss of signif. -- not used      */
  72.     STACKFAULT     /* floating point unit stack overflow       */
  73. }   _mexcep;
  74.  
  75. double _Cdecl _matherr(_mexcep __why, char _FAR *__fun, double _FAR *__arg1p,
  76.                        double  _FAR *__arg2p, double  __retval);
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80.  
  81.  
  82. #if !__STDC__
  83.  
  84. struct  exception 
  85. {
  86.     int type;
  87.     char   _FAR *name;
  88.     double  arg1, arg2, retval;
  89. };
  90.  
  91. #ifdef __cplusplus
  92. extern "C" {
  93. #endif
  94. int     _Cdecl abs   (int __x);
  95. double  _Cdecl atof  (const char _FAR *__s);
  96. double  _Cdecl hypot (double __x, double __y);
  97. long    _Cdecl labs  (long __x);
  98. int     _Cdecl matherr (struct exception _FAR *__e);
  99. double  _Cdecl poly  (double __x, int __degree, double coeffs []);
  100. double  _Cdecl pow10 (int __p);
  101.  
  102. #ifdef __cplusplus
  103.     /* use class complex instead of cabs in C++ */
  104. #else
  105. struct complex      /* as used by "cabs" function */
  106. {
  107.     double  x, y;
  108. };
  109.  
  110. #define cabs(z)     (hypot ((z).x, (z).y))
  111. #endif
  112.  
  113. #ifdef __cplusplus
  114. }
  115. #endif
  116.  
  117. /* Constants rounded for 21 decimals. */
  118. #define M_E         2.71828182845904523536
  119. #define M_LOG2E     1.44269504088896340736
  120. #define M_LOG10E    0.434294481903251827651
  121. #define M_LN2       0.693147180559945309417
  122. #define M_LN10      2.30258509299404568402
  123. #define M_PI        3.14159265358979323846
  124. #define M_PI_2      1.57079632679489661923
  125. #define M_PI_4      0.785398163397448309616
  126. #define M_1_PI      0.318309886183790671538
  127. #define M_2_PI      0.636619772367581343076
  128. #define M_1_SQRTPI  0.564189583547756286948
  129. #define M_2_SQRTPI  1.12837916709551257390
  130. #define M_SQRT2     1.41421356237309504880
  131. #define M_SQRT_2    0.707106781186547524401
  132.  
  133. #define EDOM    33      /* Math argument */
  134. #define ERANGE  34      /* Result too large */
  135.  
  136. #endif  /* !__STDC__ */
  137.  
  138. #endif
  139.