dc
TLDR
Start interactive calculator
SYNOPSIS
dc [options] [file...]
DESCRIPTION
dc is an arbitrary precision desk calculator using reverse Polish notation (RPN). Numbers and operators are entered sequentially, with operators acting on values in a stack. It supports arithmetic, comparisons, and programmable macros.
Basic operations push numbers onto the stack and apply operators: 5 3 + pushes 5 and 3, then adds them. The p command prints the top of stack. The k command sets decimal precision for division and other operations.
dc provides registers (a-z) for storing values, conditional execution, loops through macros, and string manipulation. Despite its terse syntax, it can implement complex algorithms including recursion.
PARAMETERS
FILE
File containing dc commands to execute.-e EXPR, --expression EXPR
Evaluate expression from command line.-f FILE, --file FILE
Read commands from file.-h, --help
Display help information.-V, --version
Display version information.
CAVEATS
RPN syntax can be unintuitive for users accustomed to infix notation. Error messages are minimal. Complex programs are difficult to read and debug. Some extended features vary between implementations.
HISTORY
dc is one of the oldest Unix utilities, written by Robert Morris at Bell Labs around 1969-1971. It predates the C programming language and was originally implemented in B. The bc calculator was later written as a preprocessor for dc.


