div_t(3type)
β¨ div_t, ldiv_t, lldiv_t, imaxdiv_t β¨ (the div_t family, bestie π)
okay so picture this: you're doing integer division and you want the leftover bits too, and instead of juggling two variables like a peasant, C hands you a whole lil struct for it. that's this page. it's a 3type page from the Linux man-pages, so it's all about types, not functions. sit down, grab a strawberry π, let's go.
πΈ NAME πΈ
div_t, ldiv_t, lldiv_t, imaxdiv_t β the quotient and the remainder of an integer division, packaged together like a little duo. it's giving "two besties, one struct" π
π«Ά LIBRARY π«Ά
Standard C library (libc) β nothing exotic, she's in the standard library, she's been there the whole time, we stan.
β¨ SYNOPSIS β¨
first up, from <stdlib.h>:
#include <stdlib.h>
typedef struct {
int quot; /* Quotient */
int rem; /* Remainder */
} div_t;
typedef struct {
long quot; /* Quotient */
long rem; /* Remainder */
} ldiv_t;
typedef struct {
long long quot; /* Quotient */
long long rem; /* Remainder */
} lldiv_t;
and then this one lives somewhere else entirely, from <inttypes.h>:
#include <inttypes.h>
typedef struct {
intmax_t quot; /* Quotient */
intmax_t rem; /* Remainder */
} imaxdiv_t;
no cap, that's the whole synopsis. four little structs. each one has a quot field (the quotient, obviously, main character behavior) and a rem field (the remainder, the supporting actor who is also iconic). π
π DESCRIPTION π
[[l]l]div_t is the type of the value returned by the [[l]l]div(3) function. like, all of those bracketed versions β div_t, ldiv_t, lldiv_t β they're that family. the brackets are just doing their little "pick your size" thing. π
imaxdiv_t is the type of the value returned by the imaxdiv(3) function. different header, different function, same exact energy. π¦
and that's it! that's the whole description. short and snappy, we love a concise queen.
π STANDARDS π
C11, POSIX.1-2024. periodt. β
β HISTORY β
we're going era by era, so buckle up:
div_tldiv_tβ SUSv1, C99, POSIX.1-2001.lldiv_timaxdiv_tβ C99, POSIX.1-2001.
so div_t and ldiv_t go way back, SUSv1 old, ancient, legendary ancestors π β while lldiv_t and imaxdiv_t showed up later, with C99 and POSIX.1-2001. everyone arrived eventually, it's fine, fashionably late is still a serve. πβ¨
π SEE ALSO π
the whole friend group, go say hi:
okay and for the sign-off: this gorgeous lil page is from Linux man-pages 6.20, dated 2026-02-08. go forth and divide integers responsibly, bestie π«ΆππΈ
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2020, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms