4.12 bc -- Extended Precision Calculator |
bc
can compute to at least 99 places right
of the decimal point and at least 4000 to the left. This may
not be fast and it may not be useful!
But, it can be done. bc
uses dc
.
dc
uses reverse
polish notation. It can be used from the keyboard. Most people
will probably prefer bc
.
If an expression does not include an assignment, the results are printed.
bc
is a language as well as a desk-top calculator. The syntax
is very much like "C". With the following (and more) exceptions:
Other features of the bc program are:
if
, while
, for
,
break
, and quit
.
quit
returns to the shell.
[ ]
for indexes.
bc
, when invoked with the -l
option,
has a limited math library.
When this is used you have 6 less variable names.
s(x)
-- sine function
c(x)
-- cosine function
e(x)
-- exponential
j(n,x)
-- Bessel function
l(x)
-- log
a(x)
-- arctangent
It also deals with multiple bases. The input base is stored
in ibase
. Be cautious setting conversion bases, bc
inputs
ALL numbers using ibase
.
The output base is stored in obase
.
To convert 4521 from base 7 to base 13:
obase = 13 ibase = 7 4521 result returned
The fractional precision of the calculation is maintained in
"scale
". For example:
scale=50
(This needs to be less than 100 on some systems.)
TABER CIS137
Lab 4.12: Exercise for bc
:
your name:
obase
of 100?.8414709848...........................................?????
Turn in this page.
Instructor: Louis Taber, louis.taber.at.pima at gmail dot com (520) 206-6850
My web site in Cleveland, OH
The Pima Community College web site
4.12 bc -- Extended Precision Calculator |