'\" te .\" Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved .\" Copyright 1989 AT&T .TH div 3C "24 Jul 2002" "SunOS 5.11" "Standard C Library Functions" .SH NAME div, ldiv, lldiv \- compute the quotient and remainder .SH SYNOPSIS .LP .nf #include \fBdiv_t\fR \fBdiv\fR(\fBint\fR \fInumer\fR, \fBint\fR \fIdenom\fR); .fi .LP .nf \fBldiv_t\fR \fBldiv\fR(\fBlong int\fR \fInumer\fR, \fBlong int\fR \fIdenom\fR); .fi .LP .nf \fBlldiv_t\fR \fBlldiv\fR(\fBlong long\fR \fInumer\fR, \fBlong long\fR \fIdenom\fR); .fi .SH DESCRIPTION .sp .LP The \fBdiv()\fR function computes the quotient and remainder of the division of the numerator \fInumer\fR by the denominator \fIdenom\fR. It provides a well-defined semantics for the signed integral division and remainder operations, unlike the implementation-defined semantics of the built-in operations. The sign of the resulting quotient is that of the algebraic quotient, and if the division is inexact, the magnitude of the resulting quotient is the largest integer less than the magnitude of the algebraic quotient. If the result cannot be represented, the behavior is undefined; otherwise, \fIquotient\fR * \fIdenom\fR + \fIremainder\fR will equal \fInumer\fR. .sp .LP The \fBldiv()\fR and \fBlldiv()\fR functions are similar to \fBdiv()\fR, except that the arguments and the members of the returned structure are different. The \fBldiv()\fR function returns a structure of type \fBldiv_t\fR and has type \fBlong int\fR. The \fBlldiv()\fR function returns a structure of type \fBlldiv_t\fR and has type \fBlong long\fR. .SH RETURN VALUES .sp .LP The \fBdiv()\fR function returns a structure of type \fBdiv_t\fR, comprising both the quotient and remainder: .sp .in +2 .nf int quot; /*quotient*/ int rem; /*remainder*/ .fi .in -2 .sp .LP The \fBldiv()\fR function returns a structure of type \fBldiv_t\fR and \fBlldiv()\fR returns a structure of type \fBlldiv_t\fR, comprising both the quotient and remainder: .sp .in +2 .nf long int quot; /*quotient*/ long int rem; /*remainder*/ .fi .in -2 .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Interface StabilityCommitted _ MT-LevelMT-Safe _ StandardSee \fBstandards\fR(5). .TE .SH SEE ALSO .sp .LP \fBattributes\fR(5), \fBstandards\fR(5)