1LDIV(P) POSIX Programmer's Manual LDIV(P)
2
3
4
6 ldiv, lldiv - compute quotient and remainder of a long division
7
9 #include <stdlib.h>
10
11 ldiv_t ldiv(long numer, long denom);
12 lldiv_t lldiv(long long numer, long long denom);
13
14
16 These functions shall compute the quotient and remainder of the divi‐
17 sion of the numerator numer by the denominator denom. If the division
18 is inexact, the resulting quotient is the long integer (for the ldiv()
19 function) or long long integer (for the lldiv() function) of lesser
20 magnitude that is the nearest to the algebraic quotient. If the result
21 cannot be represented, the behavior is undefined; otherwise,
22 quot * denom+rem shall equal numer.
23
25 The ldiv() function shall return a structure of type ldiv_t, comprising
26 both the quotient and the remainder. The structure shall include the
27 following members, in any order:
28
29
30 long quot; /* Quotient */
31 long rem; /* Remainder */
32
33 The lldiv() function shall return a structure of type lldiv_t, compris‐
34 ing both the quotient and the remainder. The structure shall include
35 the following members, in any order:
36
37
38 long long quot; /* Quotient */
39 long long rem; /* Remainder */
40
42 No errors are defined.
43
44 The following sections are informative.
45
47 None.
48
50 None.
51
53 None.
54
56 None.
57
59 div() , the Base Definitions volume of IEEE Std 1003.1-2001, <stdlib.h>
60
62 Portions of this text are reprinted and reproduced in electronic form
63 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
64 -- Portable Operating System Interface (POSIX), The Open Group Base
65 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
66 Electrical and Electronics Engineers, Inc and The Open Group. In the
67 event of any discrepancy between this version and the original IEEE and
68 The Open Group Standard, the original IEEE and The Open Group Standard
69 is the referee document. The original Standard can be obtained online
70 at http://www.opengroup.org/unix/online.html .
71
72
73
74IEEE/The Open Group 2003 LDIV(P)