How to do division with bc (bench calculator) and obtain fractional results?
Solution 1:
Try something like scale=2
From the man page:
scale ( expression )
The value of the scale function is the number of digits after the decimal point in the expression.
By default, the scale is 0, so no digits after the decimal are shown.
Solution 2:
Just invoke bc
with the -l
argument:
bc -l
Example:
$ bc -l
1/2
.50000000000000000000
5/3
1.66666666666666666666
10/3
3.33333333333333333333