文档详情

Engineering Problem Solving with C, Third Edition :工程用C解决问题,第三版.ppt

发布:2017-12-15约1.05万字共44页下载文档
文本预览下载声明
Numbering Systems Base two (binary) number system Two binary digits (0,1) Each digit multiplies a power of two Example: Copyright ? 2012 Pearson Education, Inc. 101102 = 1*24 + 0*23 + 1*22 + 1*21 + 0*20 = 1*16 + 0*8 + 1*4 + 1*2 + 0*1 = 16 + 0 + 4 + 2 + 0 = 2210 Numbering Systems Base eight number system Eight octal digits (0,1,2,3,4,5,6,7) Each digit multiplies a power of eight Example: Copyright ? 2012 Pearson Education, Inc. 2458 = 2*82 + 4*81 + 5*80 = 2*64 + 4*8 + 5*1 = 128 + 32 + 5 = 1658 Numbering Systems Base sixteen number system Sixteen hex digits (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F) Each digit multiplies a power of sixteen Example: Copyright ? 2012 Pearson Education, Inc. 2FB16 = 2*162 + F*161 + B*160 = 2*256 + F*16 + B*1 = 512 + 240 + 11 = 76310 Practice with Number Systems 1002 = ?8 37168 = ?2 1101001112 = ?10 3A1B16 = ?2 Copyright ? 2012 Pearson Education, Inc. Practice with Number Systems 1002 = 48 37168 = 011 111 001 1102 1101001112 = 42310 3A1B16 = 0011 1010 0001 10112 Copyright ? 2012 Pearson Education, Inc. Data Types Integer Data Type: Often represented in 4 bytes (System Dependent) Left most bit is reserved for the sign of the number Remaining 31 bits represent the magnitude of the number. Copyright ? 2012 Pearson Education, Inc. Data Types Representation of data affects the efficiency of arithmetic and logic operations. For efficiency, negative integers are often represented in their 2’s complement form. The 2’s complement of an integer is formed by negating all of the bits and adding one. Copyright ? 2012 Pearson Education, Inc. Two’s Complement Form the 2’s complement representation for the value -12710 assuming a word size of 8 bits for simplicity. 12710 = 011111112 Negate bits: Add 1:2’s complement is 1000 00012 Copyright ? 2012 Pearson Education, Inc. Two’s Complement Add 12710 to -12710 Copyright ? 2012 Pearson Ed
显示全部
相似文档