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

  1. /*------------------------------------------------------------------------
  2.  * filename - log10.cas
  3.  *
  4.  * function(s)
  5.  *       log10 - base 10 logarithm function
  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.  
  26. static  unsigned short   NANLOG [4] = {0,0,0x0480, 0xFFF8};
  27.  
  28. /*--------------------------------------------------------------------------*
  29.  
  30. Name            log10 - base 10 logarithm function
  31.  
  32. Usage           double log10(double x);
  33.  
  34. Prototype in    math.h
  35.  
  36. Description     log10 calculates the base 10  logarithm of x, which must be
  37.                 greater than zero.
  38.  
  39. Return value    log10 returns  the base 10   logarithm of x,  which must be
  40.                 greater than zero.
  41.  
  42. *---------------------------------------------------------------------------*/
  43. #pragma warn -rvl
  44. #pragma warn -use
  45.  
  46. double _FARFUNC log10( double  x )
  47. {
  48. double  temp;
  49.  
  50. asm     FLD     DOUBLE (x)
  51.  
  52. asm     mov     ax, W0 (x [6])          /* get the exponent field */
  53. asm     shl     ax, 1
  54. asm     jz      l10_zero
  55. asm     jc      l10_imaginary
  56. asm     cmp     ax, 0FFE0h
  57. asm     je      l10_infinite
  58.  
  59. #ifdef _Windows
  60.         _f87_Log10();
  61. #else
  62. asm     _FAST_  (_FLOG10_)
  63. #endif
  64.  
  65. l10_end:
  66.         return;
  67.  
  68. l10_zero:
  69. asm     mov     si, SING
  70.         temp = -HUGE_VAL;
  71. asm     jmp     short   l10_complain
  72.  
  73. l10_infinite:
  74. asm     mov     si, OVERFLOW
  75.         temp = HUGE_VAL;
  76. asm     jmp     short   l10_complain
  77.  
  78. l10_imaginary:
  79. asm     mov     si, DOMAIN
  80.         temp = *((double *) NANLOG);
  81.  
  82. l10_complain:
  83. asm     FSTP    ST(0)                   /* pop x from stack */
  84. #pragma warn -ret
  85.         return  _matherr (_SI, "log10", &x, NULL, temp);
  86. #pragma warn .ret
  87. }
  88. #pragma warn .rvl
  89. #pragma warn .use
  90.