Math using bc
suggest changebc is an arbitrary-precision calculator language. It can be used interactively or from the command line.
For example, it can print out the result of an expression:
echo '2 + 3' | bc
5
echo '12 / 5' | bc
2
For floating-point arithmetic, load the standard math library with bc -l:
echo '12 / 5' | bc -l
2.40000000000000000000
It can be used for comparing expressions:
echo '8 > 5' | bc
1
echo '10 == 11' | bc
0
echo '10 == 10 && 8 > 3' | bc
1
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents