Borland C++ reference

ldiv

raw OCR

Divides two longs, returning quotient and remainder.

Defined in header <stdlib.h>

Syntax

#include <stdlib.h>
ldiv_t ldiv(long int numer, long int denom);

Portability

DOSUNIXWindowsANSI CC++ only
■■■

Remarks

Idiv divides two longs and returns both the quotient and the remainder as an ldiv_t type, numer and denom are the numerator and denominator, respectively. The ldiv_t type is a structure of longs defined (with typedef) in stdlib.h as follows:

typedef struct {

long int quot;/* quotient */
long int rem;/* remainder */

} ldiv_t;

Return value

Idiv returns a structure whose elements are qiwt (the quotient) and rem (the remainder).

See also

Example

#include <stdlib.h>
#include <stdio.h>

int main(void)
{
   ldiv_t Ix;
   Ix = IdivdOOOOOL,  30000L);
   printf("100000 div 30000 = %ld remainder %ld\n", Ix.quot,  Ix.rem);
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.

Extraction notes

  • heading `Idiv` read as `ldiv`