Linux and Unix dc command

Quick links

About dc
Syntax
Examples
Related commands
Linux and Unix main page

About dc

Short for desk calculator, dc is an arbitrary precision arithmetic package.

Syntax

dc [filename]

filenameInput taken from file if required.

dc commands

pPrints current results
qQuits dc
cClear all values on the stack
vTake square root
iChange input base; similar to bc ibase,
oChange output base; similar to bc obase.
kSet scale factor (number of digits after decimal); similar to bc scale.
!Remainder of line is a Unix command.

Examples

dc

Enters the desk calculator, below is a short example of what can be done:

1234 - Enter base value of 1234
1234
2 * p - Takes the value of 1234 times 2 and prints value
2468
468 - p - Takes the value of 2468 and subtracts 468
2000
2 / p - Takes the value of 2000 and divides by 2.
1000
v p - Takes the value of 1000 and square roots it.
31
q - Quits the desk calucator

Related commands

bc