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

  1. /*------------------------------------------------------------------------
  2.  * filename - sin.cas
  3.  *
  4.  * function(s)
  5.  *        sin - trigonometric sine 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   NANTRIG [4] = {0,0,0x0420, 0x7FF0};
  29.  
  30. /*--------------------------------------------------------------------------*
  31.  
  32. Name        sin - trigonometric sine function
  33.  
  34. Usage        double sin(double x);
  35.  
  36. Prototype in    math.h
  37.  
  38. Description    sin  returns  the  sine  of  the  input  value.  Angles are
  39.         specified in radians.
  40.  
  41. Return value    sin returns a value in range -1 to 1.
  42.         For very  large arguments (magnitude 2^53  radians or more)
  43.         there  is no  precision. This  is "silent",  since the ANSI
  44.         spec allows no error return for this function.
  45.  
  46. *---------------------------------------------------------------------------*/
  47. #pragma warn -rvl
  48. double    sin (double x)
  49. {
  50. asm    FLD    DOUBLE (x)
  51.  
  52. asm    mov    ax, 7FF0h
  53. asm    and    ax, W0 (x [6])        /* extract the exponent field */
  54. asm    cmp    ax, (53 * 16) + 3FF0h    /* biased version of exponent 53 */
  55. asm    jae    sin_tooLarge
  56.  
  57.     if (_8087 >= 3)
  58.     {
  59. asm    db    OPCODE_FSIN
  60.     }
  61.     else
  62.     {
  63. asm    _FAST_    (_FSIN_)
  64.     }
  65. sin_end:
  66.     return;
  67.  
  68.  
  69. sin_tooLarge:
  70. asm    FSTP    ST (0)            /* pop x from stack */
  71. #pragma    warn -ret
  72.         return  _matherr (TLOSS, "sin", &x, NULL, *((double *) NANTRIG));
  73. #pragma    warn .ret
  74. }
  75. #pragma warn .rvl
  76.