《第四章 位运算课件》由会员分享,可在线阅读,更多相关《第四章 位运算课件(20页珍藏版)》请在金锄头文库上搜索。
1、第四章 位运算,位运算,位运算,算术运算,逻辑运算,算术运算,整数的算术运算 原码的算术运算 反码的算术运算 补码的算术运算,二进制补码中的加法,(17)(22)(39) Carry 1 0 0 0 1 0 0 0 1 +0 0 0 1 0 1 1 0 -Result0 0 1 0 0 1 1 1 39,二进制补码中的加法,(24)(17)(7) Carry 1 1 1 1 1 0 0 0 1 1 0 0 0 +1 1 1 0 1 1 1 1 -Result0 0 0 0 0 1 1 1 +7,二进制补码中的加法,(+127)+(+3)(+130) Carry 1 1 1 1 1 1 1 0
2、1 1 1 1 1 1 1 + 0 0 0 0 0 0 1 1 -Result 1 0 0 0 0 0 1 0 -126 (Error) An overflow has occurred.,二进制补码中的加法,浮点数的算术运算,检验符号 如果符号相同,相加其值,结果符号与原符号相同 如果符号不同,比较绝对值,绝对值大的减去小的,结果符号去绝对值大的一方 移动小数点,使两者指数相同。 将尾数进行加减运算 先规范化结果在存入内存中 检查是否存在溢出,什么是逻辑,逻辑学是研究推理和论证的学问。 例如: “张珊是中国公民 ;张珊已年满18岁;凡是年满18岁的中国公民都有选举权;所以,张珊有选举权。”
3、“菊花可以观赏,并且菊花可以入药。” “他发烧到39度是由于上呼吸道感染,或者是由于肺部感染。”,逻辑运算,逻辑运算,逻辑运算,逻辑运算,非,与,或,异或,逻辑运算,A,B,X,逻辑运算,+,A,B,X,A,B,X,门电路,Transistor晶体管 A transistor has three terminals A source源极 A base基极 An emitter, typically发射极 connected to a ground wire If the electrical signal is grounded, it is allowed to flow through a
4、n alternative route to the ground (literally) where it can do no harm,Constructing Gates,根据门的运作方式,非常容易创建非门,与非门,或非门,A,B,X,+,A,B,X,异或逻辑的实现,Adders(加法器),The result of adding two binary digits could produce a carry value(两个二进制位的加法会产生进位) Recall that 1 + 1 = 10 in base two A circuit that computes the sum of two bits and produces the correct carry bit is called a half adder(计算两个二进制位加法并产生进位的电路称为半加器),Adders,Circuit diagram representing a half adder Two Boolean expressions: sum = A B carry = AB,Adders,A circuit called a full adder takes the carry-in value into account,