Arbitrary-Precision Math With bc

Run a calculator that handles very large numbers and decimal precision.

macOSTerminalscriptingLow risk
Pipe an expression into bc, for example echo "scale=10; 4*a(1)" | bc -l.

01Command

Command
$ echo "scale=10; 4*a(1)" | bc -l

02What it does

bc is a command-line calculator language that supports arbitrary precision, bases, variables and functions. The -l flag loads the math library, enabling a(), s() and l() so you can compute pi as 4*a(1). Set scale to control decimal places.

03Risk

RiskLow risk
CompatibilitymacOS (built-in)
!Warning: bc truncates toward zero rather than rounding, and by default scale is 0 so division yields integers.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-20 · Category: Developer

06Related solutions