bc.1 (2010 09)
b
bc(1) bc(1)
NAME
bc - arbitrary-precision arithmetic language
SYNOPSIS
bc [-c][-l][file...]
DESCRIPTION
bc is an interactive processor for a language that resembles C but provides unlimited-precision arith-
metic. It takes input from any files given, then reads the standard input.
Options
bc recognizes the following command-line options:
-c Compile only. bc is actually a preprocessor for
dc which bc invokes automatically
(see dc(1)). Specifying
-c prevents invoking dc, and sends the dc input to standard out-
put.
-l causes an arbitrary-precision math library to be predefined. As a side effect, the scale
factor is set.
Program Syntax
L a single letter in the range
a through z;
E expression;
S statement;
R relational expression.
Comments
Comments are enclosed in
/* and */.
Names
Names include:
simple variables: L
array elements: L [ E ]
The words ibase,obase, and scale
stacks: L
Other Operands
Other operands include:
Arbitrarily long numbers with optional sign and decimal point.
(E)
sqrt ( E )
length ( E ) number of significant decimal digits
scale ( E ) number of digits right of decimal point
L ( E , ... , E )
Strings of ASCII characters enclosed in quotes ("").
Arithmetic Operators:
Arithmetic operators yield an E as a result and include:
+-*/%ˆ (% is remainder (not mod, see below); ˆ is power).
++ -- (prefix and append; apply to names)
=+=-=*=/=%=ˆ=
Relational Operators
Relational operators yield an R when used as E op E:
== <= >= != < >
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1