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_t
  • ldiv_t β€” SUSv1, C99, POSIX.1-2001.
  • lldiv_t
  • imaxdiv_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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms