Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ div(3C) — CX/UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

div(3C)

NAME

div, ldiv − compute quotient 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 numer by denom.  If the division is inexact, the resulting quotient is the integer of lesser magnitude that is the nearest to the algebraic quotient.  div returns a structure of type div_t, which has two members:

int quot;
int rem;

If the result cannot be represented the behavior is undefined; otherwise, quot ∗ denom + rem shall equal numer. 

Ldiv is just like div except that it takes arguments of type long int and returns a ldiv_t structure. 

CX/UX Programmer’s Reference Manual

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