82 lines
1.4 KiB
Plaintext
82 lines
1.4 KiB
Plaintext
'\"macro stdmacro
|
|
.if n .pH g3c.div @(#)div 30.2 of 12/25/85
|
|
.nr X
|
|
.if \nX=0 .ds x} DIV 3C "C Programming Language Utilities" "\&"
|
|
.if \nX=1 .ds x} DIV 3C "C Programming Language Utilities"
|
|
.if \nX=2 .ds x} DIV 3C "" "\&"
|
|
.if \nX=3 .ds x} DIV "" "" "\&"
|
|
.TH \*(x}
|
|
.SH NAME
|
|
div, ldiv \- perform integer division
|
|
.SH SYNOPSIS
|
|
.B #include <stdlib.h>
|
|
.PP
|
|
.B "div_t div (int numer, int denom);"
|
|
.PP
|
|
.B "ldiv_t ldiv (long int numer, long int denom);"
|
|
.br
|
|
.SH DESCRIPTION
|
|
.I div\^
|
|
and
|
|
.I ldiv\^
|
|
compute the quotient and remainder resulting from the division of
|
|
the integer dividend
|
|
.I numer\^
|
|
by the integer divisor
|
|
.IR denom .
|
|
If the division is inexact, the quotient will be the
|
|
nearest integer with less magnitude than the
|
|
algebraic
|
|
quotient (e.g.,
|
|
.I "div(5/2)"
|
|
yields
|
|
.IR 2 ,
|
|
and
|
|
.I "div(-5/2)"
|
|
yields
|
|
.IR -2 ).
|
|
.P
|
|
.I div\^
|
|
operates on and returns
|
|
.B int\^
|
|
quantities.
|
|
.I ldiv\^
|
|
operates on and returns
|
|
.B "long int"
|
|
quantities.
|
|
.P
|
|
Unless the result cannot be represented,
|
|
.I div\^
|
|
and
|
|
.I ldiv\^
|
|
return the result in a structure
|
|
.RB ( div_t
|
|
for
|
|
.IR div ,
|
|
.B ldiv_t\^
|
|
for
|
|
.IR ldiv )
|
|
which has two integer members: the quotient,
|
|
.IR quot ,
|
|
and the remainder,
|
|
.IR rem .
|
|
These members are of type
|
|
.B int\^
|
|
for
|
|
.IR div ,
|
|
and
|
|
.B "long int"\^
|
|
for
|
|
.IR ldiv .
|
|
.SH DIAGNOSTICS
|
|
If
|
|
.I div\^
|
|
or
|
|
.I ldiv\^
|
|
is invoked with a zero
|
|
.IR denom ,
|
|
the same integer divide-by-zero trap occurs as if the integer division
|
|
had occurred in-line.
|
|
.\" @(#)div.3c 6.2 of 10/20/83
|
|
.Ee
|