NAME

SYNOPSIS

pc
[
-n
]

DESCRIPTION

Pc
is an arbitrary precision integer calculator with a special emphasis on supporting two’s complement bit operations and working with different number bases.

Pc
reads input statements which are either expressions or control statements.
Multiple statements in one line can be separated by semicolons.
Pc
prints the value of all expressions that are not terminated by a semicolon.

Pc
can be run non-interactively by using the
-n
switch. In this case no input prompt is printed.

Expressions can use the C-like operators

+ - * ** (exponentiation)

/ % (Euclidean division, by default)

& | ^ ~ ! << >>

&& || (returning the second argument, if appropriate)

< >= < <= == !=

The $ operator performs sign extension. n$x truncates x to n bits and sign extends.
If n is omitted, it is inferred from the highest set bit (the result is always ≤ 0 in this case).

Variables can be defined using
=.
The builtin variable
@
always refers to the last printed result.

Numbers can use the prefixes
0b
(binary),
0
(octal),
0d
(decimal) and
0x
(hexadecimal).
_
in numbers can be added for readability and is ignored.

SOURCE

SEE ALSO

BUGS

With the input base set to 16, terms such as
ABC
are ambiguous.
They are interpreted as numbers only if there is no function or variable of the same name.
To force interpretation as a number, use the 0x prefix.

Arbitrary bases should be supported, but are not supported by the
mp(2)
string functions.