简单问题:问java的位操作符

lbl20020123 2004-08-03 09:25:11
java里的
按位与:&
按位或:|
异或:^ ????
左移: ???
右移:????

请给回答问号部分。
本人手头没有参考书,多谢了!
...全文
82 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jellen 2004-08-03
  • 打赏
  • 举报
回复
异或:1^1 = 0; 0^0 = 0; 1^0 = 1 //就是相同是0,不同是1
左移:<< //右边补0
右移:>> //左边补符号位
无符号右移:>>> //左边一律补0
yswift 2004-08-03
  • 打赏
  • 举报
回复
>> op1 >> op2 shift bits of op1 right by distance op2
<< op1 << op2 shift bits of op1 left by distance op2
>>> op1 >>> op2 shift bits of op1 right by distance op2 (unsigned )

& op1 & op2 bitwise and
| op1 | op2 bitwise or
^ op1 ^ op2 bitwise xor
~ ~op2 bitwise complement

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧