从二进制补码转换为符号幅度

时间:2019-02-02 22:17:17

标签: java bit signed twos-complement

所以我设法找出了大多数bits.c问题,

无论如何,我都在为此而苦苦挣扎,结果一切都是假的。

/*
 * twosComp2SignMag - Convert from two's complement to sign-magnitude
 *   where the MSB is the sign bit
 *   You can assume that x > TMin
 *   Example: twosComp2SignMag(-5) = 0x80000005.
 *   Legal ops: ! ~ & ^ | + << >>
 *   Max ops: 15
 *   Rating: 4
 */
int twosComp2SignMag(int x) {
  return 2;
}

0 个答案:

没有答案
相关问题