div
---divide two integers#include <stdlib.h> div_t div(int n, int d);Description
div_t
.
Returns
The result is represented with the structure
typedef struct { int quot; int rem; } div_t;
where the quot
field represents the quotient, and rem
the
remainder. For nonzero d, if `r = div(n,d);
' then
n equals `r.rem + d*r.quot
'.
When d is zero, the quot
member of the result has the same
sign as n and the largest representable magnitude.
To divide long
rather than int
values, use the similar
function ldiv
.
Portability
div
is ANSI, but the behavior for zero d is not specified by
the standard.
No supporting OS subroutines are required.