re: 字符集相關問題 hzpfly 2010-07-15 09:31
如果中英文混排的情況如何轉換成寬字符呢?
const char* str = "I 服了 You";
return n&(n - 1) and
return n&&(n&(n - 1)) are all wrong!
Example:
n = 110, n-1 = 101, we have n&(n-1) = 100.
So n&(n-1) is not zero, the return value is true.
We all know 110 is not 2^n.
-2^n 不是 2 的冪。所以很多回復如
return n&(n - 1)
或者
return n && (n&(n - 1))
的前提是要把 n 聲明為無符號整數。