文档详情

计算机基础第四章数据的运算技术总结.ppt

发布:2017-04-14约5.29千字共60页下载文档
文本预览下载声明
第四章 数据运算;4.1 逻辑运算;位层次上的逻辑运算;Unary and binary operations;Logical operations;Truth tables;NOT operator;Example 7;AND operator;Example 8;Inherent rule of the AND operator;OR operator;Example 9;Inherent rule of the OR operator;XOR operator;Example 10;Inherent rule of the XOR operator;Mask(掩码);Mask(掩码);Example of unsetting specific bits;Example 11;Example 12;Use the maskto AND with the target pattern. The only 0 bit (bit 7) in the mask turns off the seventh bit in the target. Target 1 1 0 0 0 1 1 1 AND Mask 1 0 1 1 1 1 1 1 ------------------ Result 1 0 0 0 0 1 1 1;Example of setting specific bits;Example 13;Example 14;Figure 4-16;Example 15;4.2 移位运算;4.2.1 逻辑移位运算;1. 逻辑移位;例题 对位模用逻辑左移运算 解 解如下所示,最左位被丢弃,0作为最右位被插入 ← 1 0 0 1 1 0 0 0 原始的 0 0 1 1 0 0 0 0 移位后;1. 循环移位;例题 对位模用逻辑左移运算 解 解如下所示,最左位被回环,成为最右位 1 0 0 1 1 0 0 0 原始的 0 0 1 1 0 0 0 1 移位后;4.2.2 算术移位运算;;例题 对位模用算术右移,模式是二进制补码格式的整数 解 解如下所示,最左位被保留,被复制到相邻的右边的位中 1 0 0 1 1 0 0 0 原始的 1 1 0 0 1 1 0 0 移位后 原始数是-103,新的数是-52,它是-103被除以2并取整的结果;例题 对位模用算术左移,模式是二进制补码格式的整数 解 解如下所示,最左位被丢弃,0作为最右位被插入 1 1 0 1 1 0 0 1 原始的 1 0 1 1 0 0 1 0 移位后 原始数是-39,新的数是-78,原始数被乘以2.因为没有下溢的发生,所以运算合法。;例题 对位模用算术左移,模式是二进制补码格式的整数 解 解如下所示,最左位被丢弃,0作为最右位被插入 0 1 1 1 1 1 1 1 原始的 1 1 1 1 1 1 1 0 移位后 原始数是127,新的数是-2,因为上溢发生,所以结果非法;例题 逻辑运算和逻辑移位运算提供了操纵位模式的工具。假设有一个模式在判断过程中需要知道使用此模式的第三位(从右起),需要知道这特殊的位是0或1. 下面显示如何找到这位的 h g f e d c b a 原始的 0 h g f e d c b 一次右移 0 0 h g f e d c 二次右移 AND 0 0 0 0 0 0 0 1 掩码 0 0 0 0 0 0 0 c 结果;4.3 算术运算;4.3.1 整数的算术运算;Rule of Adding
显示全部
相似文档