在此代碼: unsigned short int i = 3;
unsigned short int x = 30;
unsigned short int z = (~x) >> i;
在第三行似乎它確實第一移位,然後將補體(〜),甚至當我使用括號。 但是,如果我有long取代short不會出現奇怪的結果。它發生在Windows和Unix中。這是爲什麼?
我正在嘗試編寫接收整數作爲輸入並返回2的冪整數列表的ac#方法其總和等於輸入整數 例如 Input Integer :15
Output of this should be 1(2^0), 2 (2^1), 4 (2^2), 8 (2^3)
Sum of above integers is 15 = Input Integer
Input Integer :13
Output of t