dc is a cross-platform reverse-polish desk calculator which supports arbitrary-precision arithmetic. It is one of the oldest Unix utilities, predating even the invention of the C programming language; like other utilities of that vintage, it has a powerful set of features but an extremely terse syntax. Traditionally, the more user-friendly (with its infix notation) bc calculator program was implemented on top of dc, although more modern implementations are related in the opposite fashion: dc uses bc’s library for arithmetic.
This article provides some examples in an attempt to give a general flavour of the language; for a complete list of commands and syntax, one should consult the man page for one’s specific implementation.
To multiply four and five in dc (note that most of the whitespace is optional):
This translates into “push four and five onto the stack, then, with the multiplication operator, pop two elements from the stack, multiply them and push the result back on the stack.”…
Proud member of GOSKATE family