|
|
public class testing
{
public static void main(String args[])
{
int total = 5 ^ 1;
System.out.println(total);
}
}
為甚麼答案是4呢?? 而不是5呢?? |
|
|
|
|
|
|
|
|
|
|
发表于 8-7-2008 10:28 PM
|
显示全部楼层
java有"^"的吗???
不是 Math.pow(5,1)么? |
|
|
|
|
|
|
|
|
|
|
发表于 8-7-2008 11:28 PM
|
显示全部楼层
在java里的 ^ 是Bitwise Exclusive OR。
Bitwise Exclusive OR Truth Table
| First Value | Second Value
| Result
| true
| true
| false | true
| false | true | | false | true | true | false
| false
| false |
所以
bit pattern of 5
| 0101 | bit pattern of 1
| 0001
| 4 <=
| 0100
|
  |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 9-7-2008 10:42 AM
|
显示全部楼层
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|