34
1 2章 數位資料表示法 資料型態 二進位表示法 各種進位表示法的轉換 整數表示法 浮點數表示法 ASCIIUnicode 2-2 01的組合

第2章 數位資料表示法

Embed Size (px)

DESCRIPTION

 

Citation preview

  • 1. 2 ASCIIUnicode 01 2-21

2. ( 0 ) ( ) ( ) ( IC ) IC 01000001IC 8 0V +5V 0V 0V 0V 0V 0V +5V8 0 1 0 00 0 0 1 2-3 binary digitbit011 088byteByte28 2562-4 2 3. Kilo210 = 1,024 (103) KB238 KB ByteMega 20 MB2 = 1,048,576 (106)512 MBByte DVD Giga230 = 1,073,741,824 (109) GB4.7 GB Byte240 = Tera(1012) 20 TB TB Byte 1,099,511,627,776 2-5 2-63 4. Coded and Decoded 2-7 523332255523 = 5 x102 + 2 x 101 + 3Bdndn-1d2d1.r1r2rm-1rmdn x Bn-1 + dn-1 x Bn-2 + + d2 x B1 + d1 x B0 +r1 x B-1 + r2 x B-2 + + rm-1 x B-(m-1) + rm x B-mB=22-84 5. 2-910110101.11012181.8125 2-105 6. 181101101012 2-110.81250.11012 2-126 7. 0.1 0.1 0.0001100112 2-13 A 4-bit pattern can be representedby a hexadecimal digit, and vice versa. Bit Pattern Bit Pattern Hex Digit Hex Digit ------------ ------------ ------------ ------------00001000 0 800011001 1 900101010 2 A00111011 3 B01001100 4 C01011101 5 D01101110 6 E01111111 7 F 2-14 7 8. Binary to hexadecimal andHexadecimal to binary transformation 2-15110110101.1101121B5.D816 2-16 8 9. 2-17__N 2-18 9 10. A 3-bit pattern can be represented by an octal digit, and vice versa.Bit Pattern Bit Pattern Oct DigitOct Digit ------------ ------------ ------------ ------------ 000 100 0 4 001 101 1 5 010 110 2 6 011 111 3 72-19 Binary to octal and Octal to binary transformation 2-20 10 11. Taxonomy of integers8 = 00001000-811110111 111110002-21 Unsigned integer range: 0 (2N-1) 2-2211 12. Sign-and-magnitude integersIn sign-and-magnitude representation,the leftmost bit defines the sign of the number. If it is 0, the number ispositive.If it is 1, the number is negative. 2-23 Range: -(2N-1-1) +(2N-1-1) 2-24 12 13. Sign-and-magnitude integersNote: There are two 0s in sign-and-magnitude representation: positive and negative.In an 8-bit allocation: +000000000 -010000000 2-25 1 2 n - 1 (overflow)0n 3 0110Range: -(2N-1-1) +(2N-1-1) 2-2613 14. -4111010110 2-27 0 1 0110 110101101011000101001 00101001 41-41 2-2814 15. Ones complement integers Note:There are two 0s in ones complement representation: positive and negative.In an 8-bit allocation: +000000000 -011111111 2-29Ones complement integers Note: In ones complement representation,the leftmost bit defines the sign of the number.If it is 0, the number is positive.If it is 1, the number is negative.2-30 15 16. Ones complement integers Note: Ones complement means reversing all bits.If you ones complement a positive number,you get the corresponding negative number.If you ones complement a negative number,you get the corresponding positive number.If you ones complement a number twice, youget the original number. 2-31 1 2 n-1 (overflow)0n -2n-11n-10 3 010110Range: -(2N-1) +(2N-1-1) 2-3216 17. 40-40 ?40 40101000000101000800101000-40 40101000000101000801011011011000 2-33Twos complement integers 0000000000101000 1111111111011000 216-00000000001010000000000000101000Ones complement1111111111010111 10000000000000000 +111111111110110001111111111011000-) 000000000010100011111111110110002-34 17 18. Twos complement integers Note: In twos complement representation,the leftmost bit defines the sign of the number.If it is 0, the number is positive.If it is 1, the number is negative. 2-35-4028-40 2-36 18 19. 0 1 01 0110 110110001010110001010000010100040-40 2-37 2-3819 20. Twos complement integersNote: There is only one 0 in twos complement:In an 8-bit allocation:000000000 2-39 Twos complement integersNote: Twos complement can be achieved by reversing allbits except the rightmost bits up to the first 1(inclusive).If you twos complement a positive number, you getthe corresponding negative number.If you twos complement a negative number, you getthe corresponding positive number.If you twos complement a number twice, you get theoriginal number. 2-4020 21. Addition in twos complement Note: Rule of Adding Integers in Twos Complement Add 2 bits and propagate the carryto the next column. If there is a final carry after the leftmost column addition, discard it. 2-41 2-4221 22. 2-43 2-4422 23. 2-45 2-46 23 24. 2-47n bits + ()(-x) + (-y)-x 2n-x-y 2n-y 2n - x + 2n - y = 2n + (2n - (x+y)) -(x+y)2-4824 25. (x) + (-y)-y 2n-y 2n+x-y (1) x >= yx-y0; 2n (2) x