home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnuc / gen_library / rcs / modf.c,v < prev    next >
Encoding:
Text File  |  1992-07-04  |  761 b   |  51 lines

  1. head    1.1;
  2. access;
  3. symbols
  4.     version39-41:1.1;
  5. locks;
  6. comment    @ * @;
  7.  
  8.  
  9. 1.1
  10. date    92.06.08.18.31.20;    author mwild;    state Exp;
  11. branches;
  12. next    ;
  13.  
  14.  
  15. desc
  16. @initial checkin
  17. @
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @#include <inline/mathieeedoubbas.h>
  26.  
  27. /*
  28.  * modf(value, iptr): return fractional part of value, and stores the
  29.  * integral part into iptr (a pointer to double).
  30.  */
  31.  
  32. double
  33. modf (double value, double *iptr)
  34. {
  35.   /* if value negative */
  36.   if (IEEEDPTst (value) < 0)
  37.     {
  38.       /* in that case, the integer part is calculated by ceil() */
  39.       *iptr = IEEEDPCeil (value);
  40.       return IEEEDPSub (*iptr, value);
  41.     }
  42.   else
  43.     {
  44.  
  45.       /* if positive, we go for the floor() */
  46.       *iptr = IEEEDPFloor (value);
  47.       return IEEEDPSub (value, *iptr);
  48.     }
  49. }
  50. @
  51.