diff options
| author | Jacob McDonnell <jacob@jacobmcdonnell.com> | 2026-04-25 21:07:28 -0400 |
|---|---|---|
| committer | Jacob McDonnell <jacob@jacobmcdonnell.com> | 2026-04-25 21:07:28 -0400 |
| commit | 711594636704defae873be1a355a292505585afd (patch) | |
| tree | 59ee13f863830d8beba6cfd02bbe813dd486c26f /static/v10/man3/arith.3 | |
| parent | 3258a063c1f189d7b019e40e525b46bef9b9a7b1 (diff) | |
docs: Added UNIX V10 Manuals
Diffstat (limited to 'static/v10/man3/arith.3')
| -rw-r--r-- | static/v10/man3/arith.3 | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/static/v10/man3/arith.3 b/static/v10/man3/arith.3 new file mode 100644 index 00000000..d5b6a5c8 --- /dev/null +++ b/static/v10/man3/arith.3 @@ -0,0 +1,97 @@ +.TH ARITH 3 +.CT 2 math +.SH NAME +abs, sgn, gcd, lcm, min, max, labs \(mi integer arithmetic functions: +absolute value, sign, +greatest common divisor, least common multiple, minimum, maximum +.SH SYNOPSIS +.B int abs(a) +.PP +.B int sgn(a) +.PP +.B int gcd(a, b) +.PP +.B long lcm(a, b) +.PP +.B int min(a, b) +.PP +.B int max(a, b) +.PP +.B long labs(a) +.br +.B long a; +.SH DESCRIPTION +.I Abs +returns +the absolute value of +.I a. +.PP +.I Sgn +returns +\-1, 0, 1, +if +.L +\fIa\fR<0, \fIa\fR=0, \fIa\fR>0, +respectively. +.PP +.I Gcd +returns the greatest common divisor of +.I a +and +.I b. +More precisely, +.I gcd +returns the largest machine-representable +generator of the ideal generated by +.I a +and +.I b. +This means that +.B gcd(0,0) += 0, and +.B gcd(N,0) += +.B gcd(N,N) += +.BR N , +where +.B N +is the most negative integer. +.PP +.I Lcm +returns the least common multiple of +.I a +and +.I b. +When the result is representable, it satisfies +.BR "abs(a*b)== lcm(a,b)*gcd(a,b)" . +.PP +.I Min +.RI ( max ) +returns the minimum (maximum) of +.I a +and +.I b. +.SH SEE ALSO +.IR floor (3) +for +.I fabs +.SH DIAGNOSTICS +.I Abs +returns +the most negative integer when the true result is unrepresentable. +.PP +There are no guarantees about the value of +.I lcm +when the true value is unrepresentable. +.SH BUGS +The result of +.I lcm +is undefined when it doesn't fit in a long. +.br +.I Labs, +provided for +.SM ANSI +compatibility, is lonely; there is no +.I lsign, lmax, +etc. |
