mul_u64_u64_div_u64(9)
β¨ mul_u64_u64_div_u64 β¨
okay so bestie, welcome to the Kernel API Manual, section 9 π β this one's a little math baddie and she's honestly kind of iconic.
π NAME π
mul_u64_u64_div_u64 β unsigned 64bit multiply and divide π₯ (yes, she does both, main character energy fr fr)
π¦ SYNOPSIS π¦
mul_u64_u64_div_u64 (a , b , d );
πΈ ARGUMENTS πΈ
aβ the first unsigned 64bit multiplicand πbβ the second unsigned 64bit multiplicand πdβ the unsigned 64bit divisor π
π DESCRIPTION π
So here's the vibe: you multiply two 64bit values together, which gives you a whole 128bit product (glow up β¨), and then you divide that by a third value. Big numbers, no cap.
Now the tea β β the Generic code divides by 0 if d is zero, and returns ~0 on overflow. Bestie. Not the zero. π And architecture specific code may trap on zero or overflow β so like, be careful, that's not a drill π.
β RETURN β
a * b / d
π«Ά SEE ALSO π«Ά
Kernel file ./include/linux/math64.h β go read her sisters, they're all slaying in the same family tree π³π:
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_roundup(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)
that's the whole page bestie, you ate that ππ mwah!
sign-off szn: brought to you straight out of ./include/linux, dated October 2026, and yes the page is literally called mul_u64_u64_div_u64(9) β she's that girl ππ¦π
π¦ 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