roundup(3)

πŸ’– roundup(3) β€” Library Functions Manual πŸ’–

ok so bestie, welcome to roundup(3) β€” she lives in the Library Functions Manual section of your friendly neighborhood libc, and she is literally the girl who rounds things up. no cap. πŸŽ€


✨ NAME ✨

roundup β€” round up in steps πŸ’…

πŸ“š LIBRARY πŸ“š

Standard C library (libc) 🫢

🌸 SYNOPSIS 🌸

#include <sys/param.h>

roundup(x, step);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the vibe: this macro takes x and rounds it to the nearest multiple of step that is not less than x. it's giving glow-up but for numbers. ✨

and like, the typical situations where you'd call her? rounding up a pointer so it's aligned, or bumping a buffer size up so it's big enough to allocate. main character energy for memory stuff fr fr.

⚠️ but listen β€” this API is not designed to be generic, and there are some cases it just doesn't handle. and honestly? those cases aren't important for the typical use cases described above anyway. check CAVEATS below, iykyk. πŸ’€

πŸŽ€ RETURN VALUE πŸŽ€

this macro returns the rounded value. that's it, that's the tea. ⭐

🌈 STANDARDS 🌈

None. bestie is built different, she's not on any standard. πŸ™ˆ

πŸ’€ CAVEATS πŸ’€

  • the arguments may be evaluated more than once. yes, more than once. protect them if they have side effects, bestie, seriously 😭
  • x should be nonnegative, and step should be positive. fr fr, respect the range.
  • if x + step would overflow or wrap around, the behavior is undefined. not "a little weird", not "probably fine" β€” undefined. do not test her. 🚨

πŸ‘‘ SEE ALSO πŸ‘‘

ceil(3), floor(3), lrint(3), rint(3), lround(3), round(3) β€” the whole rounding-up-and-down friend group, go say hi 🌸


that's the whole page, bestie!! you ate that. periodt. πŸ’–βœ¨πŸ¦‹

this little icon was brought to you by Linux man-pages 6.20, dated 2025-05-17 β€” mwah, love you, bye πŸ‘‘πŸ’œ

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms