home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 2.ddi / MATHSRC.ZIP / LOGL.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  2.0 KB  |  87 lines

  1. /*------------------------------------------------------------------------
  2.  * filename - logl.cas
  3.  *
  4.  * function(s)
  5.  *        logl - natural logarithm function of long double
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 5.0
  10.  *
  11.  *      Copyright (c) 1987, 1992 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15.  
  16.  
  17. #pragma inline
  18. #include <asmrules.h>
  19.  
  20. #include <_math.h>
  21. #include <math.h>
  22. #include <errno.h>
  23. #include <stddef.h>
  24.  
  25. static  unsigned short   NANLOGL [5] = {0,0,0,0xC024, 0xFFFF};
  26.  
  27. /*--------------------------------------------------------------------------*
  28.  
  29. Name            logl - natural logarithm function of long double
  30.  
  31. Usage           long double logl(long double x);
  32.  
  33. Prototype in    math.h
  34.  
  35. Description     logl calculates the natural logarithm of x, which  must be
  36.                 greater than zero.
  37.  
  38. Return value    logl returns the  natural logarithm of x.
  39.  
  40. *---------------------------------------------------------------------------*/
  41. #pragma warn -rvl
  42. #pragma warn -use
  43. long double _FARFUNC logl (long double  x)
  44. {
  45. long double     temp;
  46.  
  47. asm     FLD     LONGDOUBLE (x)
  48.  
  49. asm     mov     ax, W0 (x [8])          /* get the exponent field */
  50. asm     shl     ax, 1
  51. asm     jz      log_zero
  52. asm     jc      log_imaginary
  53. asm     cmp     ax, 0FFFEh
  54. asm     je      log_infinite
  55.  
  56. #ifdef _Windows
  57.         _f87_Log();
  58. #else
  59. asm     _FAST_  (_FLOG_)
  60. #endif
  61.  
  62. log_end:
  63.         return;
  64.  
  65. log_zero:
  66. asm     mov     si, SING
  67.         temp = -_LHUGE_VAL;
  68. asm     jmp     short   log_complain
  69.  
  70. log_infinite:
  71. asm     mov     si, OVERFLOW
  72.         temp = _LHUGE_VAL;
  73. asm     jmp     short   log_complain
  74.  
  75. log_imaginary:
  76. asm     mov     si, DOMAIN
  77.         temp = *((long double *) NANLOGL);
  78.  
  79. log_complain:
  80. asm     FSTP    ST(0)                   /* pop x from stack */
  81. #pragma warn -ret
  82.         return  __matherrl (_SI, "logl", &x, NULL, temp);
  83. #pragma warn .ret
  84. }
  85. #pragma warn .rvl
  86. #pragma warn .use
  87.