do_div(9)
π do_div(9)
okay so bestie, welcome to the Kernel API Manual β this one's a lil macro from the kernel, do_div, and she's doing two things at once because she's a multitasking icon β¨
πΈ NAME
do_div β returns 2 values: calculate remainder and update new dividend π«Ά
like, she literally does both. no cap.
π SYNOPSIS
do_div (n , base );
that's it. that's the whole vibe check. π
π¦ ARGUMENTS
nβ auint64_tdividend β and heads up, she will be updated π₯ (yes, the macro writes back into her, that's the whole point)baseβ auint32_tdivisor β the thing you're dividing by π
β¨ DESCRIPTION
Summary, and I'm quoting the manpage's own summary here because it's already giving:
uint32_t remainder = n % base;
n = n / base;
so literally: grab the remainder from n % base, then overwrite n with n / base. two-for-one. ate and left no crumbs π
π RETURN
(uint32_t)remainder β the remainder, cast to uint32_t, that's your comeback value π
π NOTE
β οΈ macro parameter n is evaluated multiple times β beware of side effects! π
fr fr, this is the important one. if you pass something with a side effect in it (like n++ or a function call), it's gonna fire off more than once and that's a situation. guard your vibes. π«Ά
π§ SEE ALSO
Kernel file ./include/asm-generic/div64.h π β go read the source, it's giving main character energy.
kisses bestie, this page came to you from ./include/asm-generic, dated October 2026, and it's do_div(9) β slay, study up, and may all your remainders be correct πβ¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms