umult32(3)

πŸ“¦
version 0.34 Β· 2 versions
  • 0.34 Β· alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.30 Β· fedora 43, fedora 44, ubuntu jammy
, in alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ NAME ✨

umult32 β€” integer multiplication with overflow checking πŸ’–

okay so bestie, this is the safe multiply girlie. she multiplies two unsigned 32-bit numbers and tells you if it went sideways instead of just silently lying to your face. no cap, that's the whole vibe.


πŸŽ€ SYNTAX πŸŽ€

#include <libowfat/safemult.h>

int umult32(uint32 a,uint32 b,uint32* c);

yes you do need that include, don't skip it, the compiler will absolutely humble you 🌸


πŸ’… DESCRIPTION πŸ’…

so here's the tea, bestie. umult32 does

c = a*b

and returns 1. that's it. that's the girl. she ate. ✨

but β€” and this is the important part, the part where she becomes your main character β€” if there's an integer overflow, she does not touch c at all. she leaves it exactly the way she found it, and returns 0. 🫢

so if you get a 0 back, your c is untouched and your math was a lie. respect the return value or perish πŸ™ˆ

like, c stays alone on overflow. untouched. unbothered. not a single byte changed. she's just telling you "bestie this did not fit, i'm not doing it." πŸ’€


πŸ”₯ SEE ALSO πŸ”₯

the whole safemult friend group, they all serve πŸ¦‹


k bye ily, this was the <code>umult32(3)</code> page from the Library Functions Manual β€” stay safe out there and always check your return values πŸ’œ