mul_u64_add_u64_div_u64(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… NAME πŸ’…

mul_u64_add_u64_div_u64 β€” unsigned 64bit multiply, add, and divide. bestie it does exactly what it says on the tin, no cap 🫢

it's a kernel API manual entry, so you already know this is math64.h girlie territory ✨


✨ SYNOPSIS ✨

u64 mul_u64_add_u64_div_u64 (u64 a , u64 b , u64 c , u64 d );

πŸŽ€ ARGUMENTS πŸŽ€

  • a β€” first unsigned 64bit multiplicand. one half of the main character duo πŸ’–
  • b β€” second unsigned 64bit multiplicand. the other half, they ate fr πŸ”₯
  • c β€” unsigned 64bit addend. the little sprinkle on top after the multiply 🌸
  • d β€” unsigned 64bit divisor. the one doing the dividing, lowkey carrying the whole operation 😭

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so picture this: you multiply two 64bit values together to generate a 128bit product, then you add a third value, and then you divide by a fourth. that's the whole vibe, it's giving math chain-reaction energy πŸ’«

the Generic code divides by 0 if d is zero and returns ~0 on overflow. yes really, that's the documented behaviour, not me being dramatic πŸ™ˆ

Architecture specific code may trap on zero or overflow β€” so different arches can be like "nope" and trap instead. it's giving "depends on your arch bestie, check before you ship" πŸ’€


πŸ‘‘ RETURN πŸ‘‘

(a * b + c) / d

literally just the formula, periodt ✨


🌈 SEE ALSO 🌈

Kernel file ./include/linux/math64.h, plus the whole math64 friend group:


iykyk: this page lives in ./include/linux, dated October 2026, and it's filed under the Kernel API Manual β€” mul_u64_add_u64_div_u64(9) forever and always πŸ’œ ok that's the whole page bestie, go forth and multiply (then add, then divide) πŸ§šπŸ“
πŸ“¦ where this page comes from