BC(1) UNIX Programmer's Manual BC(1)
bc - arbitrary-precision arithmetic language and calculator
S
\bSY
\bYN
\bNO
\bOP
\bPS
\bSI
\bIS
\bS
b
\bbc
\bc [ -
\b-c
\bc ] [ -
\b-l
\bl ] [ file ... ]
D
\bDE
\bES
\bSC
\bCR
\bRI
\bIP
\bPT
\bTI
\bIO
\bON
\bN
_
\bB_
\bc is an interactive processor for a language which resem-
bles C but provides unlimited precision arithmetic. It
takes input from any files given, then reads the standard
input. The -
\b-l
\bl argument stands for the name of an arbitrary
precision math library. The syntax for _
\bb_
\bc programs is as
follows; L means letter a-z, E means expression, S means
are enclosed in /* and */.
The words `ibase', `obase', and `scale'
arbitrarily long numbers with optional sign and
length ( E ) number of significant decimal digits
scale ( E ) number of digits right of decimal point
+ - * / % ^ (% is remainder; ^ is power)
++ -- (prefix and postfix; apply to names)
Printed 7/9/88 July 28, 1987 1
BC(1) UNIX Programmer's Manual BC(1)
Functions in -
\b-l
\bl math library
All function arguments are passed by value.
The value of a statement that is an expression is printed
unless the main operator is an assignment. Either semi-
colons or newlines may separate statements. Assignment to
_
\bs_
\bc_
\ba_
\bl_
\be influences the number of digits to be retained on
arithmetic operations in the manner of _
\bd_
\bc(1). Assignments
to _
\bi_
\bb_
\ba_
\bs_
\be or _
\bo_
\bb_
\ba_
\bs_
\be set the input and output number radix
The same letter may be used as an array, a function, and a
simple variable simultaneously. All variables are global to
the program. `Auto' variables are pushed down during func-
tion calls. When using arrays as function arguments or
defining them as automatic variables empty square brackets
must follow the array name.
defines a function to compute an approximate value of the
for(i=1; i<=10; i++) e(i)
prints approximate values of the exponential function of the
Printed 7/9/88 July 28, 1987 2
BC(1) UNIX Programmer's Manual BC(1)
_
\bB_
\bc is actually a preprocessor for _
\bd_
\bc(1), which it invokes
automatically, unless the -
\b-c
\bc (compile only) option is
present. In this case the _
\bd_
\bc input is sent to the standard
/usr/lib/lib.b mathematical library
dc(1) desk calculator proper
S
\bSE
\bEE
\bE A
\bAL
\bLS
\bSO
\bO
L. L. Cherry and R. Morris, _
\bB_
\bC - _
\bA_
\bn _
\ba_
\br_
\bb_
\bi_
\bt_
\br_
\ba_
\br_
\by _
\bp_
\br_
\be_
\bc_
\bi_
\bs_
\bi_
\bo_
\bn
_
\bd_
\be_
\bs_
\bk-_
\bc_
\ba_
\bl_
\bc_
\bu_
\bl_
\ba_
\bt_
\bo_
\br _
\bl_
\ba_
\bn_
\bg_
\bu_
\ba_
\bg_
\be
No &&, ||, or ! operators.
_
\bF_
\bo_
\br statement must have all three E's.
_
\bQ_
\bu_
\bi_
\bt is interpreted when read, not when executed.
Printed 7/9/88 July 28, 1987 3