Command Prompt Calculator

Discussion in 'Windows' started by pradeep, Aug 10, 2007.

  1. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    The command processor CMD.EXE comes with a mini-calculator that can perform simple arithmetic on 32-bit signed integers:
    Code:
    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.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I didn't know that. Interesting.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice