MPE/iX Shell and Utilities Reference Manual, Vol 1

bc(1) MPE/iX Shell and Utilities bc(1)
NAME
bc — arbitrary-precision arithmetic calculation language
SYNOPSIS
bc [–i][–l][file ...]
DESCRIPTION
bc is a programming language which can perform arithmetic calculations to arbitrary preci-
sion. You can use it interactively, by entering instructions from the terminal. It can also run
programs taken from files.
If you specify file arguments on the command line, they should be text files containing bc
instructions. bc performs the instructions from those files, in the order that they appear on the
command line, and then performs instructions from the standard input. bc terminates when it
receives a quit instruction or reaches the end-of-file on standard input.
Options
bc accepts the following options.
–i puts bc into interactive mode. In this mode, bc displays a prompt when waiting for
input. In addition, it handles errors somewhat differently. Normally, when bc
encounters an error while processing a file, the interpreter displays the error message
and exits. In interactive mode, the interpreter displays the message and returns to the
prompt mode to allow debugging.
–l loads a library of standard mathematical functions before processing any other input.
This library also sets the scale to 20. For a description of the functions in the –l
library, see Built-in Functions.
The bc Language
bc is a simple but complete programming language with a syntax reminiscent of the C pro-
gramming language. This version of bc is a superset of the standard language available on
most systems. It has a number of additional features intended to make the language more flex-
ible and useful. Features which are unique to this implementation are noted in the text.
Input consists of a series of instructions that assign values to variables or make calculations.
It is also possible to define subprograms called functions which perform a sequence of instruc-
tions to calculate a single value.
bc displays the result of any line that calculates a value, but does not assign it to a variable.
For example, the instruction
2+2
Commands and Utilities 1-45