~在C語言中是按位取反的意思,
~(0xf)則要看一起運算的變數或者賦值的變數型別。
如果是unsigned char(8位),unsigned char i = ~(0xf); 那麼 ~(0Xf)=11110000(2進位制)=0xF0=240(10進位制無符號數)
如果是char(8位),char i = ~(0xf); 那麼 ~(0Xf)=11110000(2進位制)=0xF0=-16(10進位制有符號數)
如果是unsigned short(16位),unsigned short i = ~(0xf); 那麼 ~(0Xf)=1111111111110000(2進位制)=0xFFF0=65520(10進位制無符號數)
如果是short(16位),short i = ~(0xf); 那麼 ~(0Xf)=1111111111110000(2進位制)=0xFFF0=-16(10進位制有符號數)
32位,64位資料以此類推...
~在C語言中是按位取反的意思,
~(0xf)則要看一起運算的變數或者賦值的變數型別。
如果是unsigned char(8位),unsigned char i = ~(0xf); 那麼 ~(0Xf)=11110000(2進位制)=0xF0=240(10進位制無符號數)
如果是char(8位),char i = ~(0xf); 那麼 ~(0Xf)=11110000(2進位制)=0xF0=-16(10進位制有符號數)
如果是unsigned short(16位),unsigned short i = ~(0xf); 那麼 ~(0Xf)=1111111111110000(2進位制)=0xFFF0=65520(10進位制無符號數)
如果是short(16位),short i = ~(0xf); 那麼 ~(0Xf)=1111111111110000(2進位制)=0xFFF0=-16(10進位制有符號數)
32位,64位資料以此類推...