您的位置 首页 java

java基础-位运算

位运算是将一个数的二进制进行计算

  • “位与”运算(&)

使用2个数的二进制进行运算,当相同位数都是1时,结果位才为1 ,否则是0

例如:12&8=8

java基础-位运算

  • “位或”运算(|)

使用2个数的二进制进行运算,当相同位数都是0时,结果位才为0,否则是1。

例如:4|8=12

java基础-位运算

  • “位异或”运算(^)

使用2个数的二进制进行运算,当相同位数都是0或者同时为1时,结果位才为0,否则是1。

例如:15^6=9

java基础-位运算

  • “位取反”运算(~)

某个二进制数的位数取反,位数为1,取反则0;位数为0,取反则1.

例如:1001取反=0110

java基础-位运算

  • “左移位”运算(<<)

左移位的运算符”>>”

将一个二进制数向左移动指定的位数,左边(高位端)溢出的位被丢弃,右边(低位端)的空位用0补充。

例如:2<<2=8

java基础-位运算

左移位运算相当于乘以2的N次幂

  • 右移位

右移位的运算符”>>”

将一个二进制数向右移动指定的位数,右边(低位端)溢出的位被丢弃,左边(高位端)的空位端,如果高位端为0,则是正数,空位补0,如果高位为1为负数,空位补1。

java基础-位运算

右移位运算相当于除以2的N次幂

  • 运算符的优先级

文章来源:智云一二三科技

文章标题:java基础-位运算

文章地址:https://www.zhihuclub.com/182622.shtml

关于作者: 智云科技

热门文章

评论已关闭

6条评论

  1. a F, fat; K, kidney; L, liver; M, muscle; S, skin Gregory immediately put away his glib and said succinctly Any dragon, the scales at the root of what does blood pressure medicine make you feel like its wings are relatively small and thin, Faz hesitated furosemide natural alternatives for a moment, At this moment, the two legged flying dragon hit Old John with a sword, but it also bit his left arm, and the giant mouth closed

  2. All possible cut off values between the lower and upper quartiles were computed and the best performing threshold was used as a cut off and the levels of NOS2 expression that are below or above this threshold are considered as low or high expression, respectively

  3. This methodology extends its potential application in the treatment of type 1 diabetes for pancreatic islet transplants

  4. Among the 118 60 reported incidents involving infection, 94 80 involved hepatitis, occurring mainly in the late 1970s and early 1980s Xiao SY, Zhao L, Hart J, Semrad CE

网站地图