The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

div - compute the quotient and remainder of an integer division

 SYNOPSIS



#include <stdlib.h>

div_t div(int numer, int denom);

 DESCRIPTION

The div() function computes the quotient and remainder of the division of the numerator numer by the denominator denom. If the division is inexact, the resulting quotient is the integer of lesser magnitude that is the nearest to the algebraic quotient. If the result cannot be represented, the behaviour is undefined; otherwise, quot * denom + rem will equal numer.

 RETURN VALUE

The div() function returns a structure of type div_t, comprising both the quotient and the remainder. The structure includes the following members, in any order:
int quot; /* quotient */
int rem; /* remainder */

 ERRORS

No errors are defined.

 EXAMPLES

None.

 APPLICATION USAGE

None.

 FUTURE DIRECTIONS

None.

 SEE ALSO

ldiv(), <stdlib.h>.

DERIVATION

Derived from the ISO C standard.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]