]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/man/1/pc
merge
[plan9front.git] / sys / man / 1 / pc
index 9c86eba9a9311a10de4b516d6751f30f8e1d1b32..287938541de01120b32fba9d3a41380df9047539 100644 (file)
@@ -8,7 +8,7 @@ pc \- programmer's calculator
 ]
 .SH DESCRIPTION
 .I Pc
-is an arbitrary precision calculator with a special emphasis on supporting two's complement bit operations and working with different number bases.
+is an arbitrary precision integer calculator with a special emphasis on supporting two's complement bit operations and working with different number bases.
 .PP
 .I Pc
 reads input statements which are either expressions or control statements.
@@ -33,6 +33,9 @@ Expressions can use the C-like operators
 .TP
 .B < >= < <= == !=
 .PP
+The \fB$\fR operator performs sign extension. \fIn\fB$\fIx\fR truncates \fIx\fR to \fIn\fR bits and sign extends.
+If \fIn\fR is omitted, it is inferred from the highest set bit (the result is always ≤ 0 in this case).
+.PP
 Variables can be defined using
 .BR = .
 The builtin variable
@@ -105,6 +108,9 @@ Truncate each of the \fIa\d\s7i\s0\u\fR arguments to \fIn\d\s7i\s0\u\fR bits and
 .I gcd(n,m)
 The greatest common divisor of \fIn\fR and \fIm\fR.
 .TP
+.I clog(a,b)
+The ceiling of the logarithm of \fIa\fR with respect to base \fIb\fR. \fIb\fR can be omitted, in which case it defaults to 2.
+.TP
 .I minv(n,m)
 The inverse of \fIn\fR mod \fIm\fR.
 .TP