Seth Woolley's Man Viewer

div(3) - div, imaxdiv, ldiv, lldiv, div, imaxdiv, ldiv, lldiv - compute quotient and remainder of an integer division - man 3 div

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

DIV(3)                     Linux Programmer's Manual                    DIV(3)



NAME
       div,  ldiv, lldiv, imaxdiv - compute quotient and remainder of an inte-
       ger division

SYNOPSIS
       #include <stdlib.h>

       div_t div(int numerator, int denominator);
       ldiv_t ldiv(long numerator, long denominator);
       lldiv_t lldiv(long long numerator, long long denominator);

       #include <inttypes.h>

       imaxdiv_t imaxdiv(intmax_t numerator, intmax_t denominator);

DESCRIPTION
       The div() function computes the value numerator/denominator and returns
       the quotient and remainder in(1,8) a structure named(5,8) div_t that contains two
       integer members (in(1,8) unspecified order) named(5,8) quot and  rem.   The  quo-
       tient  is  rounded  towards  zero.  The result satisfies quot*denomina-
       tor+rem = numerator.

       The ldiv() and lldiv() and imaxdiv() functions do  the  same,  dividing
       numbers  of  the indicated type and returning the result in(1,8) a structure
       of the indicated name, in(1,8) all cases with fields quot  and  rem  of  the
       same type as the function arguments.

RETURN VALUE
       The div_t (etc.) structure.

EXAMPLE
       After
               div_t q = div(-5, 3);
       the values q.quot and q.rem are -1 and -2, respectively.

CONFORMING TO
       SVID  3,  BSD  4.3, ISO 9899.  The functions lldiv() and imaxdiv() were
       added in(1,8) ISO C99.

SEE ALSO
       abs(3)



                                  2003-11-01                            DIV(3)

References for this manual (incoming links)