mul_u64_u64_div_u64_roundup(9)
π mul_u64_u64_div_u64_roundup(9) π
okay bestie, welcome to the mul_u64_u64_div_u64_roundup(9) page from the Kernel API Manual β yes that's the whole title, no notes, she's a long one and she knows it π
β¨ NAME β¨
mul_u64_u64_div_u64_roundup β unsigned 64bit multiply and divide, but make it round UP π
πΈ SYNOPSIS πΈ
mul_u64_u64_div_u64_roundup (a , b , d );
like literally that's it, three args, go off π
π¦ ARGUMENTS π¦
aβ first unsigned 64bit multiplicand. she's the first one to the group chat π«Άbβ second unsigned 64bit multiplicand. the other half of the collab, we love a duo πdβ unsigned 64bit divisor. the one doing the dividing, main character energy fr fr π₯
β DESCRIPTION β
so what she does is: multiply two 64bit values together to generate a 128bit product β yes, 128 bits, she's expanding, she's thriving β and then divide and round up. iconic behaviour, no cap β¨
β οΈ okay important warning bestie, listen up: the Generic code divides by 0 ifdis zero and returns~0on overflow. meanwhile architecture specific code may trap on zero or overflow. so likeβ¦ don't be messy with your divisors, this is not a drill π
π RETURN π
(a * b + d - 1) / d
that's the whole vibe. that's the formula. slay π§
π« SEE ALSO π«
the whole friend group, all linked up π«Ά (all from the Kernel file ./include/linux/math64.h):
div_u64_rem(9)div_s64_rem(9)div64_u64_rem(9)div64_s64_rem(9)div64_u64(9)div64_s64(9)div_u64(9)div_s64(9)mul_u64_add_u64_div_u64(9)mul_u64_u64_div_u64(9)DIV64_U64_ROUND_UP(9)DIV_U64_ROUND_UP(9)DIV64_U64_ROUND_CLOSEST(9)DIV_U64_ROUND_CLOSEST(9)DIV_S64_ROUND_CLOSEST(9)roundup_u64(9)
anyway that's the page bestie π she lives in ./include/linux, dated October 2026, and this whole little deep-dive came straight from the Kernel API Manual. mwah, go multiply something responsibly πΈππ¦
π¦ 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