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

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