March 2002
Beginner
504 pages
10h 47m
English
The bc command is an arithmetic utility not limited to integers:
$ bc scale=4 8/3 2.6666 2.5 * 4.1/6.9 1.4855 quit $
In this example, you invoke bc and set scale to 4, meaning that you want it to calculate any fraction to four decimal places. You ask it to calculate 8/3, which gives 2.6666 and then a more complex calculation. Note that spaces are optional. Finally you enter quit to return to the shell prompt. bc can handle addition (+), subtraction (-), multiplication (*), division (/), remainder or modulo (%), and integer exponentiation (^). It can accurately compute numbers of any size
9238472938742937 * 29384729347298472 271470026887302339647844620892264
and can be used in shell variable assignment to assign calculated values ...
Read now
Unlock full access