home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------------------
- * filename - sin.cas
- *
- * function(s)
- * sin - trigonometric sine function
- *-----------------------------------------------------------------------*/
-
- /*[]------------------------------------------------------------[]*/
- /*| |*/
- /*| Turbo C Run Time Library - Version 3.0 |*/
- /*| |*/
- /*| |*/
- /*| Copyright (c) 1987, 1990 by Borland International |*/
- /*| All Rights Reserved. |*/
- /*| |*/
- /*[]------------------------------------------------------------[]*/
-
-
- #pragma inline
- #include <asmrules.h>
-
- #include <_math.h>
- #include <math.h>
- #include <errno.h>
- #include <stddef.h>
-
-
- static unsigned short NANTRIG [4] = {0,0,0x0420, 0x7FF0};
-
- /*--------------------------------------------------------------------------*
-
- Name sin - trigonometric sine function
-
- Usage double sin(double x);
-
- Prototype in math.h
-
- Description sin returns the sine of the input value. Angles are
- specified in radians.
-
- Return value sin returns a value in range -1 to 1.
- For very large arguments (magnitude 2^53 radians or more)
- there is no precision. This is "silent", since the ANSI
- spec allows no error return for this function.
-
- *---------------------------------------------------------------------------*/
- #pragma warn -rvl
- double sin (double x)
- {
- asm FLD DOUBLE (x)
-
- asm mov ax, 7FF0h
- asm and ax, W0 (x [6]) /* extract the exponent field */
- asm cmp ax, (53 * 16) + 3FF0h /* biased version of exponent 53 */
- asm jae sin_tooLarge
-
- if (_8087 >= 3)
- {
- asm db OPCODE_FSIN
- }
- else
- {
- asm _FAST_ (_FSIN_)
- }
- sin_end:
- return;
-
-
- sin_tooLarge:
- asm FSTP ST (0) /* pop x from stack */
- #pragma warn -ret
- return _matherr (TLOSS, "sin", &x, NULL, *((double *) NANTRIG));
- #pragma warn .ret
- }
- #pragma warn .rvl
-