home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c021 / 7.img / INCLUDE.ZIP / MATH.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-04  |  3.5 KB  |  133 lines

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