F6是二进制值11110110.
在二进制补码系统中,第一位用于指示符号.如果为0,则剩余的7位数字代表0-127.如果它是1,那么你使用按位不翻转其他7位,然后加1并否定结果.
所以:
11110110 // Negative, because the first position is 1
1110110 // Removed the leading 1
0001001 // Flip the remaining 7 bits
8 + 1 // Convert bits to decimal values (bits 4 and 1 from the right)
9 + 1 = 10 // Add the 1
Run Code Online (Sandbox Code Playgroud)
因此,F6是-10.