home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / MATHSRC.ZIP / FLOOR.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  1.3 KB  |  55 lines

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