2012-02-26 56 views

回答

10

嗯..因爲。

對於&,所述AND操作者:

0001  = 1 
0100  = 4 
---- (AND) 
0000  = 0 

|,所述OR操作者:

0001  = 1 
0100  = 4 
---- (OR) 
0101  = 5 
2

10b001,和40b100,所以,自然,1&40b0001|40b101,這是5

3

按位& =>如果兩個位都較高,則輸出較高,否則輸出爲零。

0 0 1 
1 0 0 
----- 
0 0 0 => 0 // 1 & 1 = 1 , 1 & 0 = 0 

現在嘗試一下Bitwise |。任何位都更高,輸出更高。

2

看看它的二進制形式。

1D(ecimal)= 001B(inary)

4D(ecimal)= 100B(inary)

從而

001b 
100b & (both bits have to be 1 to yield 1) 
-- 
000b = 0d 

001b 
100b | (only one on either side (or both) has to be 1 to yield 1) 
-- 
101b = 5d