HP C/iX Library Reference Manual (30026-90004)

132 Chapter5
HP C/iX Library Function Descriptions
div
div
Computes the quotient and remainder of two integers.
Syntax
#include <stdlib.h>
div_t div (int
numer
, int
denom
);
Parameters
numer
The numerator.
denom
The denominator.
Return Values
Returns a structure of type div_t, comprising the quotient and the remainder. The
structure contains the following:
int quot; /*
quotient
*/
int rem; /*
remainder
*/
Description
The div function computes and returns the quotient and the remainder of the division of
numer
by
denom
.
If the division is inexact, the sign of the resulting quotient and the algebraic quotient are
the same, and the magnitude of the resulting quotients is the largest integer less than the
magnitude of the algebraic quotient.
If the result cannot be represented, the behavior is undefined; otherwise,
quot
×
denom
+
rem
equals
numer
.
See Also
ldiv(), ANSI C 4.10.6.2