1.\" Copyright (c) 1990, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org> 4.\" Copyright (c) 2026 Aymeric Wibo <obiwac@freebsd.org> 5.\" 6.\" This code is derived from software contributed to Berkeley by 7.\" Chris Torek and the American National Standards Committee X3, 8.\" on Information Processing Systems. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 3. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.Dd February 18, 2026 35.Dt DIV 3 36.Os 37.Sh NAME 38.Nm div , 39.Nm ldiv , 40.Nm lldiv , 41.Nm imaxdiv 42.Nd return quotient and remainder from division 43.Sh SYNOPSIS 44.Lb libc 45.In stdlib.h 46.Ft div_t 47.Fn div "int numer" "int denom" 48.Ft ldiv_t 49.Fn ldiv "long numer" "long denom" 50.Ft lldiv_t 51.Fn lldiv "long long numer" "long long denom" 52.In inttypes.h 53.Ft imaxdiv_t 54.Fn imaxdiv "intmax_t numer" "intmax_t denom" 55.Sh DESCRIPTION 56The 57.Fn div , 58.Fn ldiv , 59.Fn lldiv , 60and 61.Fn imaxdiv 62functions compute the value of 63.Fa numer 64(the numerator) divided by 65.Fa denom 66(the denominator) and return the stored result in the form of the 67.Fa div_t , 68.Fa ldiv_t , 69.Fa lldiv_t , 70or 71.Fa imaxdiv_t 72types, respectively. 73These types are structs which contain two 74.Vt int , 75.Vt long , 76.Vt long long , 77or 78.Vt intmax_t 79members named 80.Va quot 81(the quotient) and 82.Va rem 83(the remainder). 84.Sh STANDARDS 85The 86.Fn div , 87.Fn ldiv , 88.Fn lldiv , 89and 90.Fn imaxdiv 91functions conform to 92.St -isoC-2023 93and 94.St -p1003.1-2024 . 95.Sh HISTORY 96The 97.Fn div 98and 99.Fn ldiv 100functions first appeared in 101.Bx 4.3 . 102The 103.Fn lldiv 104and 105.Fn imaxdiv 106functions first appeared in 107.Fx 5.0 . 108