- Div (C)
div is a function in
C programming language that takes two integers as parameters and returns the result of a division between them. It is specified in ANSI-C, and is included from thestdlib.h header when used.div always rounds towards 0, unlike ordinary integer division in C, where rounding for negative numbers is implementation-dependent.
div
has a prototype as follows::div_t div (int numerator, int denominator)
The return value,
div_t
is a specialdatatype which is specifically used in storing the results of this function. It is defined as follows:Wherequot
stores the quotient andrem
stores the remainder.ldiv and lldiv are similar functions that divide integers of type
long
andlong long
, respectively; and return a structure of typeldiv_t
andlldiv_t
, respectively.
Wikimedia Foundation. 2010.