Linux Commands Reference - Complete Linux Command Guide

Comprehensive Linux command reference with 150+ commands. Search, filter by category, and view detailed usage examples.

Share
Back to commands

bc

Arbitrary precision calculator

Syntax

bc [OPTION]... [FILE]

Common Options

-lLoad standard math library
-iInteractive mode
-qQuiet, no welcome message
--mathlibSame as -l, load math lib
scale=NSet decimal precision
ibase=NSet input number base
obase=NSet output number base

Common Examples

echo "2+3" | bc

Simple addition

echo "scale=2; 10/3" | bc

Division with 2 decimals

echo "obase=16; 255" | bc

Decimal to hexadecimal

echo "ibase=2; 11111111" | bc

Binary to decimal

echo "sqrt(2)" | bc -l

Calculate square root

bc -l

Enter interactive mode

echo "2^10" | bc

Calculate 2 to the 10th power

echo "a=5; b=3; a*b" | bc

Use variables

Related Commands

Related Tools

More Code & Dev Tools