It's special to the set command with /a option.
It's the only command that has it's own variable expansion phase.
The expansion of %variable% occurs before a command or block is executed.
The expansion of !variable! occurs when a single command is to be executed.
And when the set command is executed with /a, it tries to expand variable names, here a name consists of everything except valid mathematical operators and it must not begin with a digit.
set my=8
set var=1
set my_var=66666
set my-var=66666
set arr[4]=500
set idx=4
set /a result1=my_var
set /a result2=my-var
set /a result3=arr[%idx%]
set "result"
Output:
result1=66666
result2=7
result3=500
The evaluation of such variables to numbers have some rules, like it takes only the first number (in one of the three valid number formats 0=octal 0x for hexadecimal or for decimals).
Any non valid character stops the parsing of the number, but a leading number is still valid, if there is no valid number found, take 0.
set var_a=20
set var_b=0x20
set var_c=020
set var_d=20-5
set var_e=0xffXYZ
set /a result1=var_a
set /a result2=var_b
set /a result3=var_c
set /a result4=var_d
set /a result5=var_e
set "result"
Output:
result1=20
result2=32
result3=16
result4=20
result5=255
But even if a binary format (0b) is described in the set /? help, it does not seem to work.
set /a counter+=1syntax to increase the variable by one)