nullChapter 2 Number Systems and codes
(数制和编码) P25Chapter 2 Number Systems and codes
(数制和编码) P25Digital system are build from circuit that process binary digits -0s and 1s;
Real-life numbers,event,and conditions
binary digits
Binary number system and binary arithmetic
Encode
Keystone 2.1,2.2,2.3,2.5,2.6,2.10,2.11,2.16Introduction To Chapter 2:Digital system are build from circuit that process binary digits -0s and 1s;
Real-life numbers,event,and conditions
binary digits
Binary number system and binary arithmetic
Encode
Keystone 2.1,2.2,2.3,2.5,2.6,2.10,2.11,2.162.1 Positional Number Systems
(p26)2.1 Positional Number Systems
(p26)Positional Number Systems: a number is represented by a string of digits where each digit position has an associated weight.
(按位计数制:按各个数码的位置规定了该数所具有的数值.) For example:a Decimal number 1985
10 is called the base or radix of the number system. (10是记数制的基数;)the radix may be any integer r≧2.
Digital position(位序号) from left to right is :3、2、1、0;
position i has weight 10i 。(位序号为i位的权是10i)null1. Decimal Number D Can Be Represented as the Following (任意十进制小数 D 可表示如下):D = dp-1 dp-2 ... d1 d0 . d-1 d-2 ... d-nThe value of the number is the sum of
each digit multiplied by the corresponding
Power of the radix. null1. Decimal Number D Can Be Represented as the Following (任意十进制小数 D 可表示如下):D = dp-1 dp-2 ... d1 d0 . d-1 d-2 ... d-n推广:
B2 = ∑ b i × 2i
H16= ∑ hi × 16i nullD = dp-1 dp-2 ... d1 d0 . d-1 d-2 ... d -n10进制r=10;共有10个数码,0、1、2、3、4、5、6、7、8、9;逢10进1。
二进制r=?,共有?个数码,逢?进1 ;
8进制r=?, 共有?个数码,逢?进1 ;
16进制r=?,共有?个数码,逢?进1。 。
Example:00185.6300=185.63
Most Significant digit (MSD, 最高有效数字)
-the leftmost digit dp-1
Least Significant digit (LSD, 最低有效数字)
-the rightmost digit d -n
2、Binary Number(二进制) P26 2、Binary Number(二进制) P26Binary digits(bits):0、1
Radix:2
weight:2i
Most Significant bit (MSB, 最高有效位)
-the leftmost bit
Least Significant bit(LSB, 最低有效位)
-the rightmost bitExample:(1011101)2 =
(1×26+0×25+1×24+1×23+1×22+0×21+1×20)10
=(64+0+16+8+4+0+1)10
=(93)10NOTES:NOTES:bit(位)
1 byte(1个字节)=8bits
MEMORY:256M=256M Bytes
1KB=1024 Bytes
1MB=1024*1024 Bytes
1GB=1024*1024*1024 Bytes
There are only 10 types of people in the world:Those who understand binary and those who don’t.The represent of Binary number :
(二进制计数的表示)The represent of Binary number :
(二进制计数的表示)0、1
00、01、10、11
000、001、010、011、100、101、110、111
0000、0001、0010、0011、0100、0101、0110、0111、1000、1001、1010、1011、1100、1101、1110、1111What is the range of representable number,if you have n-bit binary number ?The represent of Binary number :
(二进制计数的表示)The represent of Binary number :
(二进制计数的表示)0、1
00、01、10、11
000、001、010、011、100、101、110、111
0000、0001、0010、0011、0100、0101、0110、0111、1000、1001、1010、1011、1100、1101、1110、1111What is the range of representable number,if you have n-bit binary number ?
0~2n-1
3. Octal Number(八进制)P273. Octal Number(八进制)P27Octal digits: 0~7
(0,1,2,3,4,5,6,7)
Radix:8 (powers of 2= 23)
Weight:8i
eg.
(127)8=(1×82+2×81+7×80)10
=(64+16+7)10
=(87)10
4. Hexadecimal Number(十六进制)P274. Hexadecimal Number(十六进制)P27Hexadecimal digits: 0~F
(0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)
Radix:16(powers of 2= 24)
weight:powers of 16 ,16ieg.
(5D)16=(5×161+13×160)10
=(80+13)10
=(93)10
nullD = dp-1 dp-2 ... d1 d0 . d-1 d-2 ... d -n10进制r=10;共有10个数码,0、1、2、3、4、5、6、7、8、9;逢10进1。
二进制r=2,共有2个数码,0 ,1, 逢2进1 ;0-1-10-11-100…….
8进制r=8, 共有8个数码,0--7,逢8进1 ;0-1-2-3-4-5-6-7-10---17….
16进制r=16,共有16个数码,逢16进1。0-1-2-3-4-5-6-7-8-9-A-B-C-D-E-F-
10---1F,……
Most Significant digit (MSD, 最高有效数字)
-the leftmost digit dp-1
Least Significant digit (LSD, 最低有效数字)
-the rightmost digit d -n2.3 General Positional-Number-System Conversions (常用数制的转换)P292.3 General Positional-Number-System Conversions (常用数制的转换)P29A number in any radix a number in radix 10
method: (利用位权展开)
Example 1:( 101.01 )2 = ( )10
( F1AC )16 = ( )10
Example 1:
( 101.01 )2 = (1 22 + 1 20 +1 2-2 )10=5.2510
( F1AC )16 = (15 163 + 1162+10161+12160)10=6186810
D = dp-1 dp-2 ... d1 d0 . d-1 d-2 ... d -nnull
Example 2:
( F1AC )16 = (15 163 + 1 162 +10161 +12160)10=6186810
Shortcut(捷径) for covering whole numbers to radix 10.
( F1AC )16 = ( ( ( 15) 16 +1 ) 16 + 10) 16 + 12=6186810
Shortcut(捷径) for covering a decimal number D to a radix r.61868÷16,the quotient (商)will be(( 1516 ) +1 ) 16 +10 ),
the remainder 余数 is 12(C);(LSB)
Next:( 1516 ) +1 ) 16 + 10) ÷16, the quotient will be
( 1516 ) +1 ) , the remainder is 10(A);
Again: ( 1516 ) +1 ) ÷16, the quotient will be ( 1516 ),
the remainder 余数 is 1;
Finally: ( 1516 )÷16, the result is 15(F).(MSB)nulla number in radix 10 A number in Binary radix
(十进制数转换成二进制)
Example:perform the following number system conversions:
(217)10 =( )2 Principle of the integer conversion:successive divisions by 2 yield successive digits of D from right to left,until all the digits of D have been derived.(P30)
整数部分的转换:除以2取余,倒着数。
nulla number in radix 10 A number in Binary radix
Example1:perform the following number system conversions:
(217)10 =( )2
∵ 2∣217 ………… ...remainder 1 b0 (LSB)
2∣108 ………….remainder 0 b1
2∣54 ………….remainder 0 b2
2∣27 ………… remainder 1 b3
2∣13 ………… remainder 1 b4
2∣6 ………… remainder 0 b5
2∣3 ………… remainder 1 b6
2∣1 ………… remainder 1 b7
0∴(217)10 =(11011001)2nullDecimal to binary For integer numbers :
divided by 2, get its remainders;Examples for 8-bit binary numbers:217—108 —54—27—13—6—3—1
1 0 0 1 1 0 1 1nullExample2:(0.3125)10 =( )2
∵0.3125 × 2 = 0.625 …………整数为0 b- 1
0.625 × 2 = 1.25 …………整数为1 b- 2
0.25 × 2 = 0. 5 …………整数为0 b- 3
0. 5 × 2 = 1.0 …………整数为1 b- 4 说明:有时可能无法得到0的结果,这时应根据转换精度的要求适当取一定位数。Additional content: (十进制小数转换成二进制)
A decimal fraction A number in Binary radix
小数部分的转换:乘2取整,正着数。∴(0.3125)10 =(0.0101)2nullFor decimal fraction numbers :
multiplied by radix, and get its integers; Examples for 8-bit binary numbers:0.17—0.34 —0.68—1.36—0.72—1.44—0.88—1.76—1.52Decimal to binary Analyze 分析 Analyze 分析Because 210=1024;(1KB) >103;
So 10-3 >2-10
a binary number which has p digits to the left of the radix point and n to the right. If the precision (精度)must achieve 2-10, then n≥10.
If the precision must achieve 10-2,because 27>102>26,so 2-6>10-2>2-7,then n ≥7.
If the precision must achieve 0.01%,because 0.01%= 10-4, 10-4约为2-13.3,then n ≥14.
B = bp-1 bp-2 ... b1 b0 . b-1 b-2 ... b -nExamples for the conversion of the decimal fraction :Examples for the conversion of the decimal fraction :example 1:convert 0.3910 to a number in radix 2.The precision must achieve 10%.
(例1、将0.3910转换为二进制数,要求精度达10%.)
example 2:convert 0.3910 to a number in radix 8.The precision must achieve 0.1%.example 1:convert 0.3910 to a number in radix 2.The precision must achieve 10%.
(例1、将0.3910转换为二进制数,要求精度达10%.)
answer:
2-4=1/16< 10%<2-3
So the binary number must has 4 bits to the right.
∵0.39 × 2 = 0.78 …………整数为0 b- 1
0.78 × 2 = 1. 56 ……… 整数为1 b- 2
0.56 × 2 = 1. 12 ……… 整数为1 b- 3
0.12 × 2 = 0.24 …………整数为0 b- 4
∴(0.39)10 =(0.0110)2
example 2:convert 0.3910 to a number in radix 8.The precision must achieve 10%.
(例1、将0.3910转换为8进制数,要求精度达10%.)
answer:
8-2< 10%<8-1
So the octal number must has 2 bits to the right.
∵0.39 × 8 = 3.12 …………整数为3 b- 1
0.12 × 8 = 0. 96 ……… 整数为0 b- 2
∴(0.39)10 =(0.30)8
Examples for the conversion of the decimal fraction :Examples for the conversion of the decimal fraction :example 1:convert 0.3910 to a number in radix 2.The precision must achieve 2-10.
(例1、将0.3910转换为二进制数,要求精度达2-10. )
example 2:convert 0.3910 to a number in radix 8.The precision must achieve 0.1%.2. Convert a Octal number to binary,
Convert a Binary number to Octal,
( P27)2. Convert a Octal number to binary,
Convert a Binary number to Octal,
( P27)(1)replace each octal digit with the 3-bit string.
三位二进制数对应一位八进制数。(101011100101)2
=(101,011,100,101)2
=(5345)8 (P27)
(6574)8 =(110,101,111,100)2
=(110101111100)2 (P28)Radix:8(powers of 2= 23)3. Convert a hexadecimal number to binary
Convert a binary number to hexadecimal3. Convert a hexadecimal number to binary
Convert a binary number to hexadecimalExample,
(9A7E)16 =(1001 1010 0111 1110)2
=(1001101001111110)2四位二进制数对应一位十六进制数。(10111010110)2 =(0101 1101 0110)2
=(5D6)16Radix:16(powers of 2= 24)QUESTION:QUESTION:What are the octal values of the four 8-bit bytes in the 32-bit number with octal representation 123456701238?
2nibbles=1byte=8bits
Table 2-1
(P28)Binary,decimal,octal,and hexadecimalnumber Table 2-1
(P28)Binary,decimal,octal,and hexadecimalnumberThink about……Think about……What can you find out?
What is AD and DA?
2.4 Binary addition and subtraction
二进制的加减法 (P32)2.4 Binary addition and subtraction
二进制的加减法 (P32)arithmetic operation:两个二进制数的算术运算
addition加法:
Carry (进位) 1 + 1 = 10
subtraction减法:
Borrows (借位) 10 – 1 = 1
Carry input(进位输入): Cin
Carry output(进位输出): Cout
Sum (本位和 ): S
Borrow input (借位输入): bin
Borrow output(借位输出): bout
Difference bit(本位差): d
EXAMPLES: P(32),P(33)EXAMPLES: P(32),P(33)nullExercisesExercisesnullHome work P(74)1、2.1 (a), (d) (e) (i) (j)
2、2.2(f)
3、2.3(f)
4 、2.4
5、2.5(g)
6、2.6(a)
7、2.7 (a ),(c)
8、think about……
Please hand your home work on next Monday!
本文档为【2-1数制】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。