| 7.3 Linux Math Tools | ||
| Learn advanced Linux commands | ||
|
dc A command-line, arbitrary-precision "reverse Polish notation" (RPN) calculator. dc is based on the concept of a stack, which is central to the operations of modern digital computer. A computer stack is not unlike a stack of kitchen plates, the last to come on stack, is the first to go out (this is also known as LIFO="last-in, first-out"). This contrasts with a queue (another important concept) where the first in is the first out (FIFO). You can perform operations only on the number(s) which is on the top of the stack. The two basic operations are: push and pop (put on the top of stack, and retrieve from the top of stack). Unary operations pop one value off the stack ("unary" means "requiring one operand"). Binary operations pop two values off the stack ("binary" means "requiring two operands"). Tertiary operations pop three values off the stack ("tertiary" means "requiring three operands"). In all cases, the result is always pushed back onto the top of stack. RPN calculators (regular, hand-held) are very popular among technically oriented people and in academia. The RPN notation never requires parentheses. History. The parentheses-free logic was developed by Polish mathematician Jan Lukasiewicz (1878-1956) before the WWII. Originally, the operator preceded the values. For computer applications, it's been modified so that the operator goes after the values, hence "reversed" in the name "reversed Polish notation".
Please note that when using the reverse Polish notation (RPN) you never need parentheses. Try man dc to read about other capabilities of dc. Next > Back to "Learn Linux Commands"
|
||

