Pages

* CALCULATION IN DOS

Calculation on command Prompt ! u knew dis???

The command processor CMD.EXE comes with a mini-calculator that can perform simple arithmetic on 32-bit signed integers:

C:\>set /a 2+2
4
C:\>set /a 2*(9/2)
8
C:\>set /a (2*9)/2
9
C:\>set /a "31>>2"
7

Note that we had to quote the shift operator since it would otherwise be misinterpreted as a "redirect stdout and append" operator.

For more information, type set /? at the command prompt.

1 comments:

Anonymous said...

Had some trouble with this... I typed in set/a 2+2 and it said "syntax error." Having done some experiments, set [a = [2+2]] followed by set almost works... it sets the variable "a" to "[2+2]."
Anyone got this to work?

Blog Archive