Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ (2) — Plan9 4th Edition

Media Vault

Software Library

Restoration Projects

Artifacts Sought

MULDIV(2)

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

­Muldiv returns a∗b/c, using a ­vlong to hold the intermediate result.  ­Umuldiv is the equivalent for unsigned integers.  They can be used to scale integer values without worry about overflowing the intermediate result. 

On some architectures, these routines can generate a trap if the final result does not fit in a ­long or ulong; on others they will silently truncate. 

Plan 9  —  March 15, 2001

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026