Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

C programming/stdlib.h/div

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

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 the stdlib.h header when used. http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1124.pdf chapter 7.20.6.2 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 special datatype which is specifically used in storing the results of this function. It is defined as follows: typedef struct { int quot; int rem; } div_t; Where quot stores the quotient and rem stores the remainder. ldiv and lldiv are similar functions that divide integers of type long and long long, respectively; and return a structure of type ldiv_t and lldiv_t, respectively. ldiv_t ldiv (long numerator, long denominator ); lldiv_t lldiv (long long numerator, long long denominator); See also stdlib.h stdio.h References External links C++ reference for std::div deep it:Div (C) pl:C/div