Provided by: manpages-dev_3.35-0.1ubuntu1_all

**NAME**

div, ldiv, lldiv, imaxdiv - compute quotient and remainder of an integer division

**SYNOPSIS**

#include<stdlib.h>div_tdiv(intnumerator,intdenominator);ldiv_tldiv(longnumerator,longdenominator);lldiv_tlldiv(longlongnumerator,longlongdenominator);#include<inttypes.h>imaxdiv_timaxdiv(intmax_tnumerator,intmax_tdenominator);Feature Test Macro Requirements for glibc (seefeature_test_macros(7)):lldiv(): _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L; orcc-std=c99

**DESCRIPTION**

Thediv() function computes the valuenumerator/denominatorand returns the quotient and remainder in a structure nameddiv_tthat contains two integer members (in unspecified order) namedquotandrem. The quotient is rounded toward zero. The result satisfiesquot*denominator+rem=numerator. Theldiv(),lldiv(), andimaxdiv() functions do the same, dividing numbers of the indicated type and returning the result in a structure of the indicated name, in all cases with fieldsquotandremof the same type as the function arguments.

**RETURN** **VALUE**

Thediv_t(etc.) structure.

**CONFORMING** **TO**

SVr4, 4.3BSD, C89. The functionslldiv() andimaxdiv() were added in C99.

**EXAMPLE**

After div_t q = div(-5, 3); the valuesq.quotandq.remare -1 and -2, respectively.

**SEE** **ALSO**

abs(3),remainder(3)

**COLOPHON**

This page is part of release 3.35 of the Linuxman-pagesproject. A description of the project, and information about reporting bugs, can be found at http://man7.org/linux/man- pages/. 2010-09-20 DIV(3)