bc-processes precision arithmetic

 <  Day Day Up  >  

bc ”processes precision arithmetic

 bc [ c ] [ l ] [ filename...] 

bc is an interactive processor for a language that resembles C, but provides unlimited precision arithmetic. It takes input from any files given, then reads the standard input.

Example A.7.
 1   bc << EOF     scale=3     4.5 + 5.6 / 3     EOF     Output : 6.366     ----------------------------- 2   bc     ibase=2     5     101 (Output)     20     10100 (Output     ^D 

EXPLANATION

  1. This is a here document. From the first EOF to the last EOF input is given to the bc command. The scale specifies the number of digits to the right of the decimal point. The result of the calculation is displayed on the screen.

  2. The number base is 2. The number is converted to binary (AT&T only).

 <  Day Day Up  >  


UNIX Shells by Example
UNIX Shells by Example (4th Edition)
ISBN: 013147572X
EAN: 2147483647
Year: 2004
Pages: 454
Authors: Ellie Quigley

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net