Command:

DIV(3) Linux Programmer's Manual DIV(3)NAMEdiv, ldiv, lldiv, imaxdiv - compute quotient and remainder of an integer divisionSYNOPSIS#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 (see feature_test_macros(7)):lldiv(): _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE; orcc-std=c99DESCRIPTIONThediv() function computes the valuenumerator/denominatorand returns the quotient and remainder in a struc- ture nameddiv_tthat contains two integer members (in unspecified order) namedquotandrem. The quotient is rounded towards 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.RETURNVALUEThediv_t(etc.) structure.CONFORMINGTOSVr4, 4.3BSD, C89. The functionslldiv() andimaxdiv() were added in C99.EXAMPLEAfter div_t q = div(-5, 3); the valuesq.quotandq.remare -1 and -2, respectively.SEEALSOabs(3), remainder(3)COLOPHONThis page is part of release 3.22 of the Linuxman-pagesproject. A description of the project, and informa- tion about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. 2007-07-26 DIV(3)