欢迎来到163文库! | 帮助中心 精品课件PPT、教案、教学设计、试题试卷、教学素材分享与下载!
163文库
全部分类
  • 办公、行业>
  • 幼教>
  • 小学>
  • 初中>
  • 高中>
  • 中职>
  • 大学>
  • 各类题库>
  • ImageVerifierCode 换一换
    首页 163文库 > 资源分类 > PPT文档下载
    分享到微信 分享到微博 分享到QQ空间

    《计算机科学导论》课件Unit-4Data-Operations.ppt

    • 文档编号:4789198       资源大小:2.84MB        全文页数:71页
    • 资源格式: PPT        下载积分:28文币     交易提醒:下载本文档,28文币将自动转入上传用户(晟晟文业)的账号。
    微信登录下载
    快捷注册下载 游客一键下载
    账号登录下载
    二维码
    微信扫一扫登录
    下载资源需要28文币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    优惠套餐(点此详情)
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、试题类文档,标题没说有答案的,则无答案。带答案试题资料的主观题可能无答案。PPT文档的音视频可能无法播放。请谨慎下单,否则不予退换。
    3、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者搜狗浏览器、谷歌浏览器下载即可。。

    《计算机科学导论》课件Unit-4Data-Operations.ppt

    1、2345Logical Operations at bit level6Figure 4.1 Logical operationsLogical Operations at bit level7Logical Operations at bit levelXNOT X0110Table 4.1 Truth table for NOT operationThe NOT operator takes one input and produces one output,which is the complement of the input.Table 4.1 shows the truth tab

    2、le for the NOT operation at bit level.A truth table lists all possible input combinations along with the corresponding outputs.8Logical Operations at bit levelTable 4.2 Truth table for AND operationXYX AND Y0000101001119Logical Operations at bit levelInherent Rule of the AND Operator:The AND operati

    3、on can be used to force(unset)individual bits in a bit string to 0.From Table 4.2,we can see that if one of the input bits is 0,the result is always 0 regardless of the other input bit,which means you dont need to check the corresponding bit value of the other input.10Logical Operations at bit level

    4、Table 4.3 Truth table for OR operationXYX OR Y000011101111The OR operator accepts two inputs and creates one output.For each pair of input bits,the result is 0 if and only if both bits are 0;otherwise,the result is 1.Table 4.3 shows the truth table for the OR operation at bit level.11Logical Operati

    5、ons at bit levelInherent Rule of the OR Operator:The OR operation can be used to force(set)individual bits in a bit string to 1.If one of the input bits is 1,the result is always 1 regardless of the other input bit,which means you dont need to check the corresponding bit value of the other input.12L

    6、ogical Operations at bit levelTable 4.4 Truth table for XOR operationXYX XOR Y000011101110The XOR(exclusive OR)operator accepts two inputs and creates one output.For each pair of input bits,the result is 0 if and only if both bits are equal;otherwise,the result is 1.Table 4.4 shows the truth table f

    7、or the XOR operation at bit level.13Logical Operations at bit level ()()x XOR yx AND NOT yORNOT x AND yThe XOR operator can be used to selectively invert(flip or NOT)bits in a bit string.If one of the input bits is 1,the result is always the inverse of the other input bit.If one of the input bits is

    8、 0,the result is exactly the value of the other input bit.Actually,the XOR operator is not a basic operator.We can simulate its functionality by using the three basic operators.The following expression shows the relation between them:14Logical Operations at bit levelTable 4.5 Truth table for XNOR op

    9、eratorXYX XNOR Y001010100111The XNOR operator accepts two inputs and creates one output.For each pair of input bits,the result is 0 if and only if both bits are not equal;otherwise,the result is 1.Table 4.5 shows the truth table for the XNOR operation at bit level.15Logical Operations at bit level (

    10、)()()x XNOR yx AND y ORNOT x AND NOT yNOTx XOR yLike XOR operator,the XNOR operator can be represented by using the three basic operators.The following expression show the relation between them:It is not a basic logical operator too and it just a reverse(NOT)of XOR16Logical Operations at bit level x

    11、 NAND yNOT x AND yx NOR yNOT x OR yThe NAND(or not-and)operator applies AND to its input bits and then inverts the output by applying NOT.For each pair of input bits,the result of applying NAND operator is 0 if and only if both bits are 1;otherwise,the result is 1.Similarly,the NOR(or not-or)operato

    12、r applies OR to its input bits and then inverts the output by applying NOT.For each pair of input bits,the result of applying NOR operator is 0 if and only if either of its input bits are 1;otherwise,the result is 1.They can be represented through following expressions:So,they are not basic logical

    13、operators either.17Logical Operations at bit levelTable 4.6 Truth table for NAND operatorXYX NAND Y001011101110The corresponding truth tables are shown in Table 4.6 and Table 4.718Logical Operations at bit levelTable 4.7 Truth table for NOR operatorXYX NOR Y00101010011019Logical Operations at patter

    14、n levelThe logical operators that can be applied to an n-bit pattern arethe same as the logical operators applied to each individual inputbit.There are some examples to help us understand this rule.Apply the NOT operator on the bit pattern 1110101020Logical Operations at pattern levelApply AND,OR,XO

    15、R,XNOR,NOR,and NAND operators on the bit patterns 10101101 and 0110101121Logical Operations at pattern levelApply AND,OR,XOR,XNOR,NOR,and NAND operators on the bit patterns 10101101 and 0110101122Logical Operations at pattern levelApply AND,OR,XOR,XNOR,NOR,and NAND operators on the bit patterns 1010

    16、1101 and 0110101123Logical Operations at pattern levelApply AND,OR,XOR,XNOR,NOR,and NAND operators on the bit patterns 10101101 and 0110101124Logic Diagram Symbol25Logic Diagram SymbolTable 4.8 Logic Diagram Symbol and Logic Function Expression26Logic Diagram SymbolTable 4.8 Logic Diagram Symbol and

    17、 Logic Function Expression27ApplicationsWe can modify a bit pattern with four binary logic operators:NOT,AND,OR,and XOR.These binary operators can complement,unset,set,or flip the target bit pattern with a mask.The mask is used to modify the target bit pattern.28ApplicationsThe most important applic

    18、ation of AND operator is to unset(force to 0)specific bits in a target bit pattern.To do that,we must use an unsetting mask of the same length as of the target bit pattern.In this technique,to unset a specific bit of the target bit pattern,the corresponding bit in the mask is set to 0.Otherwise,to l

    19、eave a bit in the target bit pattern unchanged,the corresponding bit in the mask is set to 1.For example,if you want to unset the 4 rightmost bits of an 8-bit pattern,the unsetting mask must be 11110000(Figure 4.2).29ApplicationsFigure 4.2 Example of unsetting specific bits of a bit pattern30Applica

    20、tionsSimilarly,we use OR operator to set(force to 1)specific bits in a target bit pattern.In this technique,to set a specific bit of the target bit pattern,the corresponding bit in the setting mask is set to 1.Otherwise,to leave a bit in the target bit pattern unchanged,the corresponding bit in the

    21、mask is set to 0.An example is shown in Figure 4.3.31ApplicationsFigure 4.3 Example of setting specific bits of a bit pattern32ApplicationsThe XOR operator is used to flip specific bits(0 becomes 1 and vice versa).The flip operation is functionally similar to the NOT operator.To flip a specific bit

    22、in the target bit pattern,the corresponding bit in the flipping mask is set to 1.Otherwise,to leave a bit in the target bit pattern unchanged,the corresponding bit in the mask is set to 0.Figure 4.4 shows an example of flipping specific bits.33ApplicationsFigure 4.4 Example of flipping specific bits

    23、34Applications 10011001 1011010100101100,00101100 1011010110011001,00101100 1001100110110101.aa XOR bXORba XOR bXORaa XOR bXOROther interesting applications of XOR operator are to do parity check of bit strings and to verify whether bytes sent across a network were corrupted and need retransmission,

    24、or they were sent without errors.There are interesting applications of XOR operator.XOR can be used to exchange two numbers without using any intermediate variable.If we have a=10011001 and b=10110101,then after taking three XOR operations,we will finally exchange the value of a and b.353637Arithmet

    25、ic operations on integers38Arithmetic operations on integers39Arithmetic operations on integers)1()(BABABA40Arithmetic operations on integers(+35)and(+29)in twos complement form are represented as 00100011 and 00011101 for an 8 bit memory location.The result remains same for any location size.The re

    26、sult is 64 in decimal.41Arithmetic operations on integers A=(11100010)2 B=(00100010)2B B1022242Arithmetic operations on integers A=(11100010)2 B=(00100010)243Arithmetic operations on integers A=(11100010)2 B=(00100010)2244Arithmetic operations on integersInteger A=(+127)and B=(+3)are stored in twos

    27、complement form.Show how B is added to A.A=(01111111)2,B=(00000011)2A is added to B and the result is stored in R.Obviously,we get an error here:A+B=R=-126(=01111110)130.We will discuss this issue in next section.45Arithmetic operations on integers46Arithmetic operations on integers122-11NNx1-N2-121

    28、-N47Arithmetic operations on integersFigure 4.5 Overflow 1-82-121-848Arithmetic operations on integersAs we can see from Figure 4.6,when we reach the number 127 and add 3 to 127,the final result is-126 rather than 130.Figure 4.6 Twos Complement representation(clockwise)49Arithmetic operations on rea

    29、ls1.Check the signs.a)If the signs are same,add the numbers and assign the common sign to the result.b)If the signs are different,take the absolute valuesof the numbers,subtract the smaller from the larger,and use the sign of the larger for the result.All arithmetic operations can be applied to real

    30、s stored in floating-point format.In this section,we only show rules for addition and subtraction of reals.Addition and subtraction operation rules for floating-point number are basically the same.The basic steps are as follows:50Arithmetic operations on reals51Arithmetic operations on integers52Ari

    31、thmetic operations on integersShow how the computer finds the result of(+21.75)+(+16.4375)=+38.1875.Because the exponents are the same,so we dont need to align.We apply addition operation on the combinations of sign and mantissa directly.Then we have following result:53Arithmetic operations on integ

    32、ersShow how the computer finds the result of(+21.75)+(+16.4375)=+38.1875.Now the result needs to be normalized.We decrement the exponent once and shift the de-normalized mantissa to the left one position:So the final result is R=+2132127 1.001100011=+38.1875,as expected.54Arithmetic operations on re

    33、als55Arithmetic operations on realsIn Figure 4.7,the fminN means the minimum positive number that a computer system can represent,which is a number very close to zero point.Then,the interval(-fminN,fminN),is called underflow gap.In early design of computer system,any number inside the underflow gap

    34、would be set to zero.That kind of process is called“flush-to-zero underflow”.We usually use natural logarithm to avoid arithmetic underflow issues.Figure 4.7 Underflow gap 5657Logical shift operations58Logical shift operationsFigure 4.8 Logical shift operations59Logical shift operationsFigure 4.9 Ci

    35、rcular shift operationsThe circular right-shift operation shifts every bit to the right.The leftmost bit replaced by the rightmost bit.The circular left-shift operation works conversely.Figure 4.9 shows these two operations on 8-bit patterns.60Logical shift operations61Logical shift operations62Logi

    36、cal shift operations63Arithmetic shift operations64Arithmetic shift operationsFigure 4.10 Arithmetic shift operations65Arithmetic shift operationsNote that the MSB retains there.We can see that the result is-40,which is exactly the half value of original value,-80.66Arithmetic shift operations67 For more details about the subject discussed in this chapter,the following books are recommended.68697071


    注意事项

    本文(《计算机科学导论》课件Unit-4Data-Operations.ppt)为本站会员(晟晟文业)主动上传,其收益全归该用户,163文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上传内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(点击联系客服),我们立即给予删除!




    Copyright@ 2017-2037 Www.163WenKu.Com  网站版权所有  |  资源地图   
    IPC备案号:蜀ICP备2021032737号  | 川公网安备 51099002000191号


    侵权投诉QQ:3464097650  资料上传QQ:3464097650
       


    【声明】本站为“文档C2C交易模式”,即用户上传的文档直接卖给(下载)用户,本站只是网络空间服务平台,本站所有原创文档下载所得归上传人所有,如您发现上传作品侵犯了您的版权,请立刻联系我们并提供证据,我们将在3个工作日内予以改正。

    163文库