Forrest logo
back to the dc tool

dc:tldr:3212f

dc: Start an interactive session.
$ dc
try on your machine

The "dc" command stands for "desk calculator" and is a command-line calculator tool available on Unix-like operating systems. It is used for performing arithmetic calculations using Reverse Polish Notation (RPN).

RPN is a mathematical notation system in which calculations are performed by manipulating a stack of numbers. In simple terms, instead of using traditional arithmetic expressions like "2 + 3", you would enter the numbers first and then specify the operation. For example, to add 2 and 3 using dc, you would input "2 3 +".

Here are some common operations you can perform using the dc command:

  • Addition: To add two numbers (e.g., 2 and 3), you would enter "2 3 +".
  • Subtraction: To subtract two numbers (e.g., 5 and 2), you would enter "5 2 -".
  • Multiplication: To multiply two numbers (e.g., 4 and 3), you would enter "4 3 *".
  • Division: To divide two numbers (e.g., 8 by 2), you would enter "8 2 /".

In addition to basic arithmetic calculations, dc supports several other advanced mathematical functions and operations. It can also be used for managing variables, conditionals, loops, and storing values in registers.

It is important to note that dc operates in a command-line interface, so you would need to open a terminal or command prompt to use it.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the dc tool