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

  1. /*------------------------------------------------------------------------
  2.  * filename - sqrtl.cas
  3.  *
  4.  * function(s)
  5.  *        sqrtl - calculates square root of long double
  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   NANSQRTL [5] = {0,0,0,0xC001,0x7FFF};
  26.  
  27. /*--------------------------------------------------------------------------*
  28.  
  29. Name            sqrtl - calculates square root of long double
  30.  
  31. Usage           long double     sqrtl (long double  x);
  32.  
  33. Prototype in    math.h
  34.  
  35. Description     sqrtl calculates the square root of input value.
  36.  
  37. Return value    sqrtl returns the square root of input value.
  38.                 If the input value is less than 0, sqrtl returns 0 and sets
  39.                 errno to
  40.                         EDOM    Domain error
  41. *---------------------------------------------------------------------------*/
  42. #pragma warn -rvl
  43. long double _FARFUNC sqrtl (long double  x)
  44. {
  45. asm     FLD     LONGDOUBLE (x)
  46.  
  47. asm     mov     ax, x [8]
  48. asm     shl     ax, 1
  49. asm     jz      sqrtl_zero
  50. asm     jc      sqrtl_imaginary
  51.  
  52. asm     FSQRT
  53.  
  54. sqrtl_zero:                     /* zero = sqrtl (zero) */
  55. sqrtl_end:
  56.         return;
  57.  
  58.  
  59. sqrtl_imaginary:
  60. asm     FSTP    st (0)                  /* pop x from stack     */
  61. #pragma warn -ret
  62.         return  __matherrl (DOMAIN, "sqrtl", &x, NULL, *((long double *) NANSQRTL));
  63. #pragma warn .ret
  64. }
  65. #pragma warn .rvl
  66.