ldiv
ldiv_t  ldiv ( long int numer, long int denom );
stdlib.h
  cplusplus.com  

Divide two long integer values.
  numer is divided by denom. Quotient and remainder are returned in a ldiv_t structure.

Parameters.

numer
Numerator.
denom
Denominator.

Return Value.
  A ldiv_t structure is returned:

typedef struct {
   long int quot;
   long int rem;
} ldiv_t;
ldiv_t structure is defined in stdlib.h and has two members of type long int: quot representing the quotient, and rem representing the remainder.

Portability.
  Defined in ANSI-C.

Example.

/* ldiv example */
#include <stdio.h>
#include <stdlib.h>

main ()
{
  ldiv_t divresult;
  divresult = ldiv (65537,179);
  printf ("65537 / 179 = %d ( %d", divresult.quot, divresult.rem);
  return 0;
}
Output:
65537 / 179 = 366 ( 23

See also.
  div


© The C++ Resources Network, 2000