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

  1. /*------------------------------------------------------------------------
  2.  * filename - floorl.cas
  3.  *
  4.  * function(s)
  5.  *        floorl - rounds down a 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.  
  23. /*--------------------------------------------------------------------------*
  24.  
  25. Name            floorl - rounds down a long double
  26.  
  27. Usage           long double floorl(long double x);
  28.  
  29. Prototype in    math.h
  30.  
  31. Description     floorl finds the largest integer not greater than x.
  32.  
  33. Return value    floorl returns the integer found as a long double.
  34.  
  35. *---------------------------------------------------------------------------*/
  36. #pragma warn -rvl
  37. long double _FARFUNC floorl (long double x)
  38. {
  39. asm     FLD     LONGDOUBLE (x)
  40.  
  41. asm     mov     ax, x [8]
  42. asm     and     ax, 7FFFh
  43. asm     cmp     ax, 3FFFh + 64  /* 2^64, maximum long double precision */
  44. asm     ja      dlm_beyond
  45.  
  46. asm     mov     ch, 04          /* iNDP-87 control bits for floorl mode */
  47.         __round();
  48.  
  49. dlm_beyond:                     /* magnitudes beyond 2^53 have no fraction */
  50. dlm_end:
  51.         return;
  52. }
  53. #pragma warn .rvl
  54.