home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Science / Science.zip / gmt_os2.zip / src / math / w_exp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-16  |  1.1 KB  |  50 lines

  1.  
  2. /* @(#)w_exp.c 1.3 95/01/18 */
  3. /*
  4.  * ====================================================
  5.  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  6.  *
  7.  * Developed at SunSoft, a Sun Microsystems, Inc. business.
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software is freely granted, provided that this notice 
  10.  * is preserved.
  11.  * ====================================================
  12.  */
  13.  
  14. /* 
  15.  * wrapper exp(x)
  16.  */
  17.  
  18. #include "fdlibm.h"
  19.  
  20. #ifdef __STDC__
  21. static const double
  22. #else
  23. static double
  24. #endif
  25. o_threshold=  7.09782712893383973096e+02,  /* 0x40862E42, 0xFEFA39EF */
  26. u_threshold= -7.45133219101941108420e+02;  /* 0xc0874910, 0xD52D3051 */
  27.  
  28. #ifdef __STDC__
  29.     double exp(double x)        /* wrapper exp */
  30. #else
  31.     double exp(x)            /* wrapper exp */
  32.     double x;
  33. #endif
  34. {
  35. #ifdef _IEEE_LIBM
  36.     return __ieee754_exp(x);
  37. #else
  38.     double z;
  39.     z = __ieee754_exp(x);
  40.     if(_LIB_VERSION == _IEEE_) return z;
  41.     if(finite(x)) {
  42.         if(x>o_threshold)
  43.             return __kernel_standard(x,x,6); /* exp overflow */
  44.         else if(x<u_threshold)
  45.             return __kernel_standard(x,x,7); /* exp underflow */
  46.     } 
  47.     return z;
  48. #endif
  49. }
  50.