Miscellaneous

bc

Arbitrary precision calculator language supporting math expressions.

Synopsis

syntax
bc [OPTION]... [FILE]...

Examples

Calculate 2 to the power of 10
echo '2^10' | bc
Division with 4 decimal places
echo 'scale=4; 22/7' | bc
Square root using math library
echo 'sqrt(144)' | bc -l
Convert 255 to hexadecimal
echo 'obase=16; 255' | bc

Common options

FlagDescription
-lLoad math library (enables sine, cosine, etc)
-qQuiet — don't print welcome banner
-sPOSIX mode

About bc

The `bc` command arbitrary precision calculator language supporting math expressions. Utility commands cover a broad range of everyday tasks from date manipulation and arithmetic to terminal control and system documentation.

These tools fill in the gaps between major categories and are frequently used in shell scripts, cron jobs, and interactive sessions. The command accepts 3 commonly used flags shown above, though the full set of options is available in the man page (`man bc`).

The 4 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.

Related commands

More Miscellaneous Commands

Other commands in the Miscellaneous category

Related tools