码迷,mamicode.com
首页 > 其他好文 > 详细

逻辑运算与位移运算

时间:2015-03-11 17:16:12      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

异或运算
True ⊕ False = True
False ⊕ True = True
False ⊕ False = False
True ⊕ True = False
同或运算
True ⊙ False = False
False ⊙ True = False
False ⊙ False = Ture
True ⊙ True = Ture
或运算
True  || False = True
False || True = True
False || False = False
True  || True = True
与运算
True  && False = False
False && True = False
False && False = False
True  && True = True
非运算
┐True = False
┐False = True


位移运算
左移:2<<2 = 8
右移:8>>2 = 2
右移一位相当于除2,右移n位相当于除以2的n次方
在数字没有溢出的前提下,对于正数和负数,左移一位都相当于乘以2的1次方,左移n位就相当于乘以2的n次方。

逻辑运算与位移运算

标签:

原文地址:http://blog.csdn.net/yixian918/article/details/44200691

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!