f78 div[divide two integers]

Contents|Index|Previous|Next

div
[divide two integers]

SYNOPSIS
#include <stdlib.h>
div_t
div(int n, int d);

DESCRIPTION
div divides n/d, returning quotient and remainder as two long integers in a structure, div_t.

RETURNS
The result is represented with the following example.

   typedef struct
   {
      int
quot;
      int
rem;
   } div_t;

The previous example shows where the quot field represents the quotient, and rem represents the remainder.

For nonzero, d, if r=div(n,d);, then n equals r.rem + d*r.quot.

To divide long rather than int values, use the similar function, ldiv.

COMPLIANCE
div is ANSI.

No supporting OS subroutines are required.

0