home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_04 / 1004010d < prev    next >
Text File  |  1992-03-04  |  351b  |  17 lines

  1. /* ldiv function */
  2. #include <stdlib.h>
  3.  
  4. ldiv_t (ldiv)(long numer, long denom)
  5.     {    /* compute long quotient and remainder */
  6.     ldiv_t val;
  7.  
  8.     val.quot = numer / denom;
  9.     val.rem = numer - denom * val.quot;
  10.     if (val.quot < 0 && 0 < val.rem)
  11.         {    /* fix remainder with wrong sign */
  12.         val.quot += 1;
  13.         val.rem -= denom;
  14.         }
  15.     return (val);
  16.     }
  17.