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

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