Could you please advice what using "&" or "^" in SET command means (I haven't found any explanation by using Google).
For example, following Windows batch code block
SET V_COMMAND=3
SET /A V_FLAG="%V_COMMAND%&2"
echo VFlag is: %V_FLAG%
produces:
VFlag is: 2
But I haven't any opinion about what command above does.
Also there is another case with " ^ ":
SET V_COMMAND=3
SET /A V_FLAG="%V_COMMAND%^3"
echo VFlag is: %V_FLAG%
For this case output is:
VFlag is: 0
Since you are using set /a
, the indicated characters are bitwise operators:
& = bitwise AND = 1 if both bits are 1
^ = bitwise XOR = 1 if only one of the two bits is 1
So if a
is 10
( 1010
in binary) and b
is 13 ( 1101
in binary)
1010 1010
1101 1101
---- ----
1000 = a & b 0111 = a ^ b
Or in your case with 3 dec = 11 bin
and 2 dec = 10 bin
11 11
10 11
-- --
10 = 3&2 = 2 00 = 3^3 = 0
Those are bitwise operators - &
is bitwise AND, and ^
is bitwise XOR. These bitwise operators are only available with SET /A
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.