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

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