dc
Quick Reference
Command Name:
dc
Category:
calculator
Platform:
linux
Basic Usage:
Common Use Cases
- 1
Complex calculations
Perform arbitrary-precision arithmetic calculations using RPN notation
- 2
Scripted math
Execute mathematical operations in scripts without floating-point errors
- 3
Base conversion
Convert numbers between different number bases (decimal, hex, octal, etc.)
- 4
Stack manipulation
Work with stack-based data structures for complex operations
Syntax
dc [options] [file...]
Options
Option | Description |
---|---|
-e expr | Evaluate expression |
-f file | Read commands from file |
-h, --help | Display help information and exit |
-V, --version | Output version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the dc
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
Start dc in interactive modedc
echo "5 3 + p" | dc
echo "7 2 - p" | dc
echo "4 6 * p" | dc
echo "20 4 / p" | dc
Advanced Examples:
Calculate with arbitrary precision (scale)echo "10 k 1 3 / p" | dc