HP-UX Reference (11i v1 00/12) - 3 Library Functions A-M (vol 6)

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man3/!!!intro.3c
________________________________________________________________
___ ___
d
div(3C) div(3C)
NAME
div(), ldiv() - integer division and remainder
SYNOPSIS
#include <stdlib.h>
div_t div(int numer, int denom);
ldiv_t ldiv(long int numer, long int denom);
DESCRIPTION
div() 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.
ldiv() Similar to div(), 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.
APPLICATION USAGE
div() and ldiv() are thread-safe and async-cancel-safe.
WARNINGS
Behavior is undefined if denom is zero.
SEE ALSO
floor(3M).
STANDARDS CONFORMANCE
div(): AES, SVID3, XPG4, ANSI C
ldiv(): AES, SVID3, XPG4, ANSI C
HP-UX Release 11i: December 2000 1 Section 3147
___
___