Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ldiv(3) — bsd — Apollo Domain/OS SR10.3.5

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

abs(3)

DIV(3)                               BSD                                DIV(3)



NAME
     div, ldiv - integer division

SYNOPSIS
     #include <stdlib.h>

     div_t div(numer, denom)
     int numer;
     int denom;

     ldiv_t ldiv(lnumer, ldenom)
     long int lnumer;
     long int ldenom;

DESCRIPTION
     div computes the quotient and remainder of the division of int numer by
     the int denom.  It returns the quotient and remainder in the structure
     div_t, which <stdlib.h> defines as

          typedef struct {
                  int quot;
                  int rem;
          } div_t;

     If the division is inexact, the resulting quotient is the integer of
     lesser magnitude that is the nearest to the algebraic quotient.  If the
     result cannot be represented, the behavior is undefined; otherwise,

          quot * denom + rem = numer

     ldiv is similar to div, except that the arguments and the members of the
     returned structure (which is of type ldiv_t) all are of the type long
     int.

SEE ALSO
     abs(3)

NOTE
     Parts of this discussion are adapted from ANS X3.159-1989.

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026