summaryrefslogtreecommitdiff
path: root/static/unix-v10/man3/arith.3
diff options
context:
space:
mode:
Diffstat (limited to 'static/unix-v10/man3/arith.3')
-rw-r--r--static/unix-v10/man3/arith.397
1 files changed, 97 insertions, 0 deletions
diff --git a/static/unix-v10/man3/arith.3 b/static/unix-v10/man3/arith.3
new file mode 100644
index 00000000..d5b6a5c8
--- /dev/null
+++ b/static/unix-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.