Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>ldiv() divide two longs</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 ldiv()                  Divide Two Longs

 #include   <stdlib.h>

 ldiv_t     ldiv(numer,denom);
 long       numer;
 long       denom;

    ldiv() divides two longs, the numerator 'numer' and the denominator
    'denom'.  The result is returned in the structure ldiv_t which is
    defined in <stdlib.h>:

     typdef struct {
          long  quot;              /* quotient */
          long  rem;                    /* remainder */
     } ldiv_t;

       Returns:     The structure div_t whose elements are the result of
                    the divide performed: the quotient 'quot' and the
                    remainder 'rem'.

   -------------------------------- Example ---------------------------------

    The following statements divide two longs and print the result.

           #include <stdlib.h>

           main()
           {
               ldiv_t rslt;
               long num = 32000, den = 512;

               rslt = ldiv(num,den);
               printf("%ld div %ld = %ld",num,den,rslt.quot);
               if (rslt.rem != 0)
                   printf(", remainder %ld\n",rslt.rem);
           }


See Also: div()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson