umult16(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

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

okay bestie, listen up, because this one is short but it's lowkey a lifesaver 🫢 it lives in the Library Functions Manual and it's giving "tiny function, huge main character energy" ✨


🌸 NAME 🌸

umult16 β€” integer multiplication with overflow checking πŸ’…


πŸŽ€ SYNTAX πŸŽ€

#include <libowfat/safemult.h>

int umult16(uint16 a,uint16 b,uint16* c);

no cap, that's the whole vibe. two numbers in, one pointer out 🌈


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea β˜• β€” umult16 does c=a*b and returns 1. that's it. that's the function. it multiplied. it slayed. periodt πŸ’…βœ¨

but wait, there's more, because this is the safe one 🧚

In case of an integer overflow, umult16 leaves c alone and returns 0. 😭

so like, if the math would blow past what fits, it does not touch your c, it does not pretend everything's fine, it just quietly returns 0 and lets you handle it. no silent chaos. no undefined nonsense. just honesty πŸ’– that's the whole point of the safemult header β€” it's the friend who tells you when you've had enough πŸ“

so: return value 1 = you ate. return value 0 = overflow, c is untouched, try again with a bigger type maybe πŸ‘‘


⭐ SEE ALSO ⭐

the signed siblings 🫢 go say hi.


and that's the page, bestie πŸ’œ this was umult16(3) from the Library Functions Manual β€” short, sweet, and out here protecting your integers since forever. mwah, stay overflowing with love and never with your uint16 πŸ˜ŒπŸ’–πŸŽ€