mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
No need to have 4 separate manpages for these functions. Reviewed by: ziaee, rpokala, des Approved by: rpokala, des Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D55360
108 lines
3.0 KiB
Plaintext
108 lines
3.0 KiB
Plaintext
.\" Copyright (c) 1990, 1991, 1993
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
.\" Copyright (c) 2001 Mike Barcroft <[email protected]>
|
|
.\" Copyright (c) 2026 Aymeric Wibo <[email protected]>
|
|
.\"
|
|
.\" This code is derived from software contributed to Berkeley by
|
|
.\" Chris Torek and the American National Standards Committee X3,
|
|
.\" on Information Processing Systems.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\" 3. Neither the name of the University nor the names of its contributors
|
|
.\" may be used to endorse or promote products derived from this software
|
|
.\" without specific prior written permission.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
.\" SUCH DAMAGE.
|
|
.\"
|
|
.Dd February 18, 2026
|
|
.Dt DIV 3
|
|
.Os
|
|
.Sh NAME
|
|
.Nm div ,
|
|
.Nm ldiv ,
|
|
.Nm lldiv ,
|
|
.Nm imaxdiv
|
|
.Nd return quotient and remainder from division
|
|
.Sh SYNOPSIS
|
|
.Lb libc
|
|
.In stdlib.h
|
|
.Ft div_t
|
|
.Fn div "int numer" "int denom"
|
|
.Ft ldiv_t
|
|
.Fn ldiv "long numer" "long denom"
|
|
.Ft lldiv_t
|
|
.Fn lldiv "long long numer" "long long denom"
|
|
.In inttypes.h
|
|
.Ft imaxdiv_t
|
|
.Fn imaxdiv "intmax_t numer" "intmax_t denom"
|
|
.Sh DESCRIPTION
|
|
The
|
|
.Fn div ,
|
|
.Fn ldiv ,
|
|
.Fn lldiv ,
|
|
and
|
|
.Fn imaxdiv
|
|
functions compute the value of
|
|
.Fa numer
|
|
(the numerator) divided by
|
|
.Fa denom
|
|
(the denominator) and return the stored result in the form of the
|
|
.Fa div_t ,
|
|
.Fa ldiv_t ,
|
|
.Fa lldiv_t ,
|
|
or
|
|
.Fa imaxdiv_t
|
|
types, respectively.
|
|
These types are structs which contain two
|
|
.Vt int ,
|
|
.Vt long ,
|
|
.Vt long long ,
|
|
or
|
|
.Vt intmax_t
|
|
members named
|
|
.Va quot
|
|
(the quotient) and
|
|
.Va rem
|
|
(the remainder).
|
|
.Sh STANDARDS
|
|
The
|
|
.Fn div ,
|
|
.Fn ldiv ,
|
|
.Fn lldiv ,
|
|
and
|
|
.Fn imaxdiv
|
|
functions conform to
|
|
.St -isoC-2023
|
|
and
|
|
.St -p1003.1-2024 .
|
|
.Sh HISTORY
|
|
The
|
|
.Fn div
|
|
and
|
|
.Fn ldiv
|
|
functions first appeared in
|
|
.Bx 4.3 .
|
|
The
|
|
.Fn lldiv
|
|
and
|
|
.Fn imaxdiv
|
|
functions first appeared in
|
|
.Fx 5.0 .
|