GNU bc¶
bc is a tool that does math on the CLI.
Examples¶
Divide one number into another and show two decimal places¶
The scale variable sets the number of significant digits.
echo "scale=2 ; 7 / 3" | bc
Convert decimal to hexadecimal¶
echo "obase=16 ; 10" | bc
Convert hexadecimal to binary¶
echo "ibase=16 ; obase=2 ; AF" | bc