Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

div - divide with integers

&pagelevel(4)&pagelevel

Syntax

#include <stdlib.h>

div_t div(int numer, int denom);

Description

div() computes the quotient and remainder of the division numer / denom.
The sign of the quotient is that of the algebraic quotient, and the magnitude of the quotient
is the highest integer less than or equal to the absolute value of the algebraic quotient.

The remainder is expressed by the following equation:

quotient * divisor + remainder = dividend

Return val.

Structure of type div_t

if successful. The structure contains both the quotient quot and the
remainder rem as integer values.

See also

ldiv(), stdlib.h.