Chapter 3 Data types, Operators, and Expressions Preparations ◆各种进制之间的转换 ● convert Binary、 Octal、 Hexadecimal into decimal 例(110112=1×23+1×2+1×23+0×22+1×2+1×2=(59) 例(136) 8=1x82+3×81+6×80=(94)0 例(1F2A)6=1×16+15×162+2×16+10×16=(7978
2 Preparations ❖各种进制之间的转换 ⚫convert Binary 、Octal、Hexadecimal into Decimal 1 0 5 4 3 2 1 0 2 例 (111011) = 1 2 +1 2 +1 2 + 0 2 +1 2 +1 2 =(59) 1 0 2 1 0 例 (136)8 = 18 + 38 + 68 =(94) 1 0 3 2 1 0 1 6 例 (1F2A) = 116 +1516 + 216 +1016 =(7978) < > Chapter 3 Data types , Operators , and Expressions
Chapter 3 Data types, Operators, and Expressions 各种进制之间的转换 ● convert Binary、 Octal、 Hexadecimal into decimal 方法:连续除以基,从低到高记录余数,直至商为0 例把十进制数59转换成二进制数 例把十进制数159转换成八进制数 例把召址付9转癫大进制数 229 1209条3 1802余2 16争余1 201 159)=(232B 01 (459)10=(1CB)6 (59)0=(111011)2
3 方法:连续除以基,从低到高记录余数,直至商为0 例 把十进制数59转换成二进制数 2 59 2 29 2 14 2 7 2 3 2 1 0 (59)10=(111011)2 1 1 0 1 1 1 1 1 1 0 1 1 余 余 余 余 余 余 例 把十进制数159转换成八进制数 8 159 8 19 8 2 0 (159)10=(237)8 2 3 7 余 7 余 3 余 2 例 把十进制数459转换成十六进制数 16 459 16 28 16 1 0 (459)10=(1CB)16 1 C B 余11 余12 余 1 Chapter 3 Data types , Operators , and Expressions ❖各种进制之间的转换 ⚫convert Binary 、Octal、Hexadecimal into Decimal
Chapter 3 Data types, Operators, and Expressions ● Binary and Octal Binary into Octal:从右向左,每3位一组(不足3位 左补0),转换成八进制 令 Octal into Binary:用3位二进制数代替每一位八制数 000~0 001~1 例(1101001)2=(001101001)2=(151)|00~2 011~3 100~4 例(246)=(010,100110=(101001102101~5 111~7
4 ⚫Binary and Octal ❖Binary into Octal:从右向左,每3位一组(不足3位 左补0),转换成八进制 ❖Octal into Binary :用3位二进制数代替每一位八制数 例 (1101001)2=(001,101,001)2=(151)8 例 (246)8=(010,100,110)2=(10100110)2 000 ~ 0 001 ~ 1 010 ~ 2 011 ~ 3 100 ~ 4 101 ~ 5 110 ~ 6 111 ~ 7 < > Chapter 3 Data types , Operators , and Expressions
Chapter 3 Data types, Operators, and Expressions o Binary and Hexadecimal 0000~0 0001~1 0010~2 ☆ Binary into Hexadecimal:从右向左,100-3且(不足4 位左补0)01004六进制 0101~5 0110~6 冷 Hexadecimal into Binary:用4位二进011-7一位十 六进制数10008 1001~9 1010~A 1011~B 1100~C 1101~D 1110~E l111~F 例(11010101111012(0011,0101,01111101)2=(357D)16 例(4B9E)6=(0100,1011,1001,1110)2=(100101110011102 5
5 ⚫Binary and Hexadecimal ❖Binary into Hexadecimal :从右向左,每4位一组(不足4 位左补0),转换成十六进制 ❖Hexadecimal into Binary :用4位二进制数代替每一位十 六进制数 例 (11010101111101)2=(0011,0101,0111,1101)2=(357D)16 例 (4B9E)16=(0100,1011,1001,1110)2=(100101110011110)2 0000 ~ 0 0001 ~ 1 0010 ~ 2 0011 ~ 3 0100 ~ 4 0101 ~ 5 0110 ~ 6 0111 ~ 7 1000 ~ 8 1001 ~ 9 1010 ~ A 1011 ~ B 1100 ~ C 1101 ~ D 1110 ~ E 1111 ~ F < > Chapter 3 Data types , Operators , and Expressions
Chapter 3 Data types, Operators, and Expressions 口 Byte and Bit 765432 0 Memory以Byte为单元组成 每个Byte有一个 Address 一个Byte一般由8个Bt组成 每个Bit的值是0或1 765432 23456789 10
6 ❑Byte and Bit • Memory以Byte为单元组成 • 每个Byte有一个Address • 一个Byte一般由8个Bit组成 • 每个Bit的值是0或1 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 10 ……... < > 7 6 4 3 2 5 1 Chapter 3 Data types , Operators , and Expressions