Linux and Unix dc command
Quick links
About dc
Syntax
Examples
Related commands
Linux and Unix main page
Short for desk calculator, dc is an arbitrary precision arithmetic package.
dc [filename]
| filename | Input taken from file if required. |
dc commands
| p | Prints current results |
| q | Quits dc |
| c | Clear all values on the stack |
| v | Take square root |
| i | Change input base; similar to bc ibase, |
| o | Change output base; similar to bc obase. |
| k | Set scale factor (number of digits after decimal); similar to bc scale. |
| ! | Remainder of line is a Unix command. |
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
