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

  1. /*------------------------------------------------------------------------
  2.  * filename - tanl.cas
  3.  *
  4.  * function(s)
  5.  *        tanl - long double trigonometric tangent 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. static  unsigned short   NANTRIGL [5] = {0,0,0,0xC021, 0x7FFF};
  26.  
  27. /*--------------------------------------------------------------------------*
  28.  
  29. Name            tanl - trigonometric tangent function
  30.  
  31. Usage           long double tanl(long double x);
  32.  
  33. Prototype in    math.h
  34.  
  35. Description     tanl  returns the  tangent of  the input  value. Angles are
  36.                 specified in radians.
  37.  
  38. Return value    tanl returns any value for valid angles. For angles close to
  39.                 pi/2 or -pi/2, tanl returns 0 and errno is set to
  40.                         ERANGE  Result out of range
  41.                 For very  large arguments (magnitude 2^63 or greater) all
  42.                 precision is lost. This occurs  "silently" since the ANSI C
  43.                 spec does  not specify an  error return.
  44.  
  45. *---------------------------------------------------------------------------*/
  46. #pragma warn -rvl
  47. long double _FARFUNC tanl (long double  x)
  48. {
  49. asm     FLD     LONGDOUBLE (x)
  50.  
  51. asm     mov     ax, 7FFFh
  52. asm     and     ax, W0 (x [8])          /* extract the exponent field */
  53. asm     cmp     ax, 63 + 3FFFh          /* biased version of exponent 63 */
  54. asm     jae     tanl_tooLarge
  55.  
  56. #ifdef _Windows
  57.         _f87_Tangent();
  58. #else
  59.         if (_8087 >= 3)
  60.         {
  61. asm     db      OPCODE_FSINCOS
  62. asm     FDIV
  63.         }
  64.         else
  65.         {
  66. asm     _FAST_  (_FTAN_)
  67.         }
  68. #endif
  69.  
  70. tanl_end:
  71.     return;
  72.  
  73.  
  74. tanl_tooLarge:                          /* total loss of precision */
  75. asm     FSTP    ST(0)                   /* pop x from stack */
  76.  
  77. #pragma warn -ret
  78.         return  __matherrl (TLOSS, "tanl", &x, NULL, *((long double *) NANTRIGL));
  79. #pragma warn .ret
  80. }
  81. #pragma warn .rvl
  82.