Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

div(3)

Name

div, ldiv − integer division

Syntax

#include <stdlib.h>

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

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

Description

The div and ldiv functions return the quotient and remainder of the division of the numerator numer by the denominator denom. 

The return types div_t and ldiv_t are defined, in stdlib.h, as follows:

typedef struct {
intquot;/* quotient */
intrem;/* remainder */
}div_t;/* result of div() */
 typedef struct {
longquot;/* quotient */
longrem;/* remainder */
}ldiv_t;/* result of ldiv() */

Restrictions

If division by zero is attempted, the behavior of div and ldiv is undefined.
 

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