web analytics
Wednesday, July 23, 2025
HomeHow-to GuidesHow to Calculate Using Command Prompt in Windows (Quick CMD Math Guide)

How to Calculate Using Command Prompt in Windows (Quick CMD Math Guide)

Yes, you can perform arithmetic calculations directly from the Command Prompt. The Command Prompt isn't just for running system commands

Generally, for doing any calculation on Windows, we open the calculator app or use spreadsheet Excel. However, there’s another powerful tool built right into the operating system that many people overlook, which is the Windows Command Line, also known as Command Prompt.

Yes, you can perform arithmetic calculations directly from the Command Prompt. The Command Prompt isn’t just for running system commands; it is also capable of performing fast and accurate arithmetic operations like addition, subtraction, multiplication, division, and even modulus. Calculating arithmetic expressions on the command line is more straightforward and expressive. Because when solving some complex logic, the command line comes in very handy. In this guide, you’ll learn how to perform simple and complex calculations right from the Windows Command Line without needing any external tool or calculator app.

DOS Shell has a built-in mini calculator to perform simple arithmetic calculations on 32-bit signed integers. The “SET” with /a switch DOS command is used to perform calculations on the command line.

To know more about this command type set /? at the command prompt.

set /a expressionCalculate using dos command line in windows

Here are some expressions below

C:\>set /a 3+3 will output 6
C:\>set /a 3*3 will output 9
C:\>set /a  8/4 will output 2
C:\>set /a 2+2 will output 4
C:\>set /a 5*(2/2)+10 will output 15
C:\>set /a (5*2)/2+10 will output 15
C:\>set /a “15>>2” will output 3

It also supports other types of operators. While using a logical or modulus operator, always enclose the expression string in quotes.

The following table lists the operators supported for /a in descending order of precedence.

OperatorOperation performed
< >Grouping
* / % + –Arithmetic
<< >>Logical shift
&Bitwise AND
^Bitwise exclusive OR
|Bitwise OR
= *= /= %= += -= &= ^= |= <<= >>=Assignment
,Expression separator

Note: It overflows values for decimal integers. It eliminates the decimal point value and round of the integer. i.e., 9/2 will result in 4 instead of 4.5

Roshan Karkera
Roshan Karkera
Roshan Karkera is a passionate blogger and a software engineer by profession, driven by a love for technology, science, and continuous learning. With a strong belief in sharing knowledge, he started this blog to inspire and inform readers through simple, insightful content. When he's not coding or exploring the latest in tech, you’ll find him writing about ideas that matter. Connect with him on Twitter or your favorite social platform to stay updated.
RELATED ARTICLES

5 COMMENTS

  1. thanks for specifying below that it doesn't support flotting point numbers, and i was trying to figuring out y the output i m getting diffrent

  2. The fact that it doesn’t accept subdecimals makes it completely unreliable, and therefore useless.

    For example: 8/9=0.8888888888888889 but the command line returns 0 (zero).
    That is, it omits the digits after the decimal point, and No, it does Νot Round the result.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular