Skip to main content

SET: DOS Command Line Calculator

There are two methods to do arithmetic calculations in Windows XP. Either open the Microsoft Calculator program (Start -> Run -> calc.exe) or simply open the good old MS-DOS command prompt window (Start -> cmd.exe)

DOS shell has a built-in mini calculator in the form of SET DOS command to perform simple arithmetic on 32-bit signed integers. The SET command together used with the /a switch displays the final value of the expression.

Here's the SET syntax (type set /? to display the complete help)

set /a expression

Here are some examples of the SET command:

C:\>set /a 2+2 will output 4

C:\>set /a 2*(9/2) will output 8

C:\>set /a (2*9)/2 will output 9

C:\>set /a "31>>2" will output 7

The DOS calculator SET is more versatile than the Google Search calculator. It supports the Shift operator (>> or <<) and Octal or Hexadecimal to Decimal conversions.

More on SET | Windows XP DOS Commands | Windows Shell team | Channel9