blob: 36eb7b995bd9d0565913d2425b5a894fd529d7d7 [file] [log] [blame]
rsccfa37a72004-04-10 18:53:55 +00001.TH MULDIV 3
2.SH NAME
3muldiv, umuldiv \- high-precision multiplication and division
4.SH SYNOPSIS
5.B #include <u.h>
6.br
7.B #include <libc.h>
8.PP
9.B
rscc8b63422005-01-13 04:49:19 +000010long muldiv(long a, long b, long c)
rsccfa37a72004-04-10 18:53:55 +000011.PP
12.B
13ulong umuldiv(ulong a, ulong b, ulong c)
14.SH DESCRIPTION
15.I Muldiv
16returns
17.BR a*b/c ,
18using a
19.B vlong
20to hold the intermediate result.
21.I Umuldiv
22is the equivalent for unsigned integers.
23They can be used to scale integer values without worry about
24overflowing the intermediate result.
25.PP
26On some architectures, these routines can generate a trap if the
27final result does not fit in a
28.B long
29or
30.BR ulong ;
31on others they will silently truncate.