home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / MATH.ZIP / LOG10.CAS < prev    next >
Encoding:
Text File  |  1990-06-07  |  2.2 KB  |  87 lines

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