wrapping_sub(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… wrapping_sub(9)

okay so this is a page from the Kernel API Manual and it's about wrapping_sub β€” yes bestie, subtraction that's allowed to wrap around, on purpose, no cap πŸŽ€


✨ NAME ✨

wrapping_sub β€” intentionally perform a wrapping subtraction πŸŒ€

like, the wrapping is the point, it's not a bug, it's a feature πŸ’…


🌸 SYNOPSIS 🌸

wrapping_sub (type , a , b );

three things go in, one thing comes out, and the vibes are immaculate ✨


πŸ¦‹ ARGUMENTS πŸ¦‹

  • type β€” the type for the result of the calculation πŸ‘‘ this is what your answer is gonna be, so pick it with intention
  • a β€” the minuend; the value you're subtracting from 🫢 the main character of this operation, honestly
  • b β€” the subtrahend; the value you subtract from a 🌸 the supporting role, but she delivers
ngl the naming is lowkey giving math class but fr fr a - b and you're done πŸ“

πŸ’– DESCRIPTION πŸ’–

Returns the potentially wrapped-around subtraction β€” and the whole reason this exists is so you don't trip any of the wrap-around sanitizers that might be enabled 😭✨

like bestie, the sanitizers will absolutely jump you if you do unsigned wrap math the "normal" way. this is the intentional, sanctioned, no-sneaky-surprises way to do it. the wrap is expected, the wrap is documented, the wrap is slaying πŸ‘‘

it's giving "I know exactly what I'm doing" energy and I'm obsessed πŸ’œ


🌈 SEE ALSO 🌈

the kernel file ./include/linux/overflow.h is literally right there holding the whole overflow family together 🧚 and here's the entire squad, all (9) sections, no gatekeeping:


anyway that's the whole page, go forth and subtract with intent πŸ’œπŸ¦‹

signed, sealed, delivered from ./include/linux β€” October 2026 edition, mwah πŸ˜˜πŸŽ€

πŸ“¦ where this page comes from