! ~ &^| +
我如何才能知道一個32位的數字是TMAX?
TMax是最大二進制補碼數。
我的想法至今都被:
int isTMax(int x)
{
int y = 0;
x = ~x;
y = x + x;
return !y;
}
這僅僅是其中很多事情我都沒有成功嘗試之一,但我只是想不出TMAX的屬性,它會給我回TMAX的。與其他所有整數相比,像將tmax添加到自身將是唯一的。
下面是實際的問題:
/*
* isTMax - return 1 if x is the maximum, two's complement number,
* and 0 return otherwise.
* Legal ops: ! ~ &^| +
* Max ops: 10
* Rating: 1
*/
int isTMax(int x) {
int y = 0;
x = ~x;
y = x + x;
return !y;
}
int是32位,所以簽訂的最大可能會是0x7FFFFFFF的
什麼是TMAX?最大的無符號(或有符號)整數? – GWW
我想你需要詳細說明什麼是TMax。 – NPE
最大二進制補碼數。對不起,不詳細。 – David