Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ldiv(3C) — HP-UX 7.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

floor(3M)

DIV(3C)

NAME

div, ldiv − integer division and remainder

SYNOPSIS

#include <stdlib.h>

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

ldiv_t ldiv (numer, denom)
long int numer, denom;

DESCRIPTION

The div function computes the quotient and remainder of the division of the numerator numer by the denominator denom. If the division is inexact, the sign of the resulting quotient is that of the algebraic quotient, and the magnitude of the resulting quotient is the largest integer less than the magnitude of the algebraic quotient. If the result can be represented, the result is returned in a structure of type div_t (defined in stdlib.h) having members quot and rem for the quotient and remainder respectively. Both members have type int and values such that quot * denom + rem = numer. If the result cannot be represented, the behavior is undefined.

The ldiv function is similar to the div function, except that the arguments each have type long int and the result is returned in a structure of type ldiv_t (defined in stdlib.h) having long int members quot and rem for the quotient and remainder respectively. 

WARNINGS

The behavior is undefined if denom is 0. 

SEE ALSO

floor(3M). 

STANDARDS CONFORMANCE

div: ANSI C

ldiv: ANSI C

Hewlett-Packard Company  —  HP-UX Release 7.0: Sept 1989

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