div64_u64_rem(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… div64_u64_rem β€” kernel API manual, but make it cute

okay so bestie, you know how the kernel is literally obsessed with doing math on huge numbers and never ever letting anything overflow? yeah. this is one of those functions. it's the unsigned 64-bit divide, but with a 64-bit divisor, and it also hands you back the remainder. two for the price of one, periodt. ✨

It lives in the Linux Kernel API Manual (section 9 β€” the kernel API girlies), and yes this is a real documentation page, not me making things up. 🫢


✨ NAME ✨

div64_u64_rem β€” unsigned 64bit divide with 64bit divisor and remainder

like, both operands are unsigned 64-bit, the divisor is also 64-bit (not a lil baby 32-bit one), and you get the remainder too. the way that this function does the absolute most and still stays tidy πŸ’…


🌸 SYNOPSIS 🌸

u64 div64_u64_rem (u64 dividend , u64 divisor , u64 *remainder );

that's it. that's the whole vibe check. three things go in, and one thing comes out plus a sneaky little side channel. 😭


πŸŽ€ ARGUMENTS πŸŽ€

  • dividend β€” the unsigned 64bit dividend. this is the number you're chopping up. the main character of the operation, honestly. πŸ‘‘
  • divisor β€” the unsigned 64bit divisor. this is the thing doing the chopping. also 64bit, and yes that matters, that's the whole point of this function existing, iykyk. πŸ”₯
  • remainder β€” pointer to unsigned 64bit remainder. you pass in an address and it writes the leftover into it. so you're not just getting the remainder, you're being handed the remainder through a pointer. very coder of you. πŸ¦‹

⭐ RETURN ⭐

here's the tea: it sets *remainder, then returns dividend / divisor.

so, like, the pointer gets written first, and the return value is the quotient β€” dividend / divisor. two results, one call. no cap, that's efficient. πŸ’–

ngl bestie, remember that *remainder is an out parameter. if you pass a bogus pointer, that's on you β€” the docs just say it sets it. πŸ™ˆ

🌈 SEE ALSO 🌈

the whole friend group, all from the kernel file ./include/linux/math64.h:

that's sixteen whole functions and macros, bestie. sixteen. the math64.h girlies ate and left absolutely no crumbs. πŸ“


and that's the page!! πŸ’œ this lil gem came out of ./include/linux, dated October 2026, and it's from the Kernel API Manual 'cause that's where all the div and mul besties hang out. mwah, go divide something huge responsibly 🧚 ✨

πŸ“¦ where this page comes from