MULDIV(3)
π
MULDIV(3) β muldiv, umuldiv: high-precision multiplication and division π
okay bestie, welcome to the Library Functions Manual page for MULDIV(3) π this oneβs a tiny little API with big βmath but make it safeβ energy, and weβre obsessed.
β¨ NAME β¨
muldiv, umuldiv β high-precision multiplication and division π
π¦ SYNOPSIS π¦
#include <u.h>
#include <libc.h>
long muldiv(long a, long b, long c)
ulong umuldiv(ulong a, ulong b, ulong c)
πΈ DESCRIPTION πΈ
so muldiv returns a*b/c, and it uses a vlong to hold the intermediate result β yes, itβs giving βwe do the messy part somewhere roomierβ π
β¨
umuldiv is the exact same idea but for unsigned integers. these two are here so you can scale integer values without worrying about overflowing the intermediate result. iconic behavior, honestly π«Ά
β οΈ real talk, bestie: on some architectures, these routines can generate a trap if the final result does not fit in alongorulong; on others they will silently truncate. so likeβ¦ know ur architecture, okay? ππ
thatβs the whole MULDIV(3) page β the footer just signs it MULDIV(3), so hereβs ur cute little sign-off: stay precise, stay unsigned when u need to, and catch u in the next manpage ππβ¨
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms