390 likes | 607 Vues
Learn about analog and digital information, decimal, binary, hexadecimal, and octal number systems in digital electronics. Explore methods for converting decimal numbers to binary and understand the importance of different number systems.
E N D
Analog • Analog information is made up of a continuum of values within a given range • At its most basic, digital information can assume only one of two possible values: one/zero, on/off, high/low, true/false, etc.
Digital • Digital Information is less susceptible to noise than analog information • Exact voltage values are not important, only their class (1 or 0) • The complexity of operations is reduced, thus it is easier to implement them with high accuracy in digital form • BUT: Most physical quantities are analog, thus a conversion is needed
Digital Number Systems • Many number systems are used in digital electronics: • Decimal number system (base 10) • Binary number system (base 2) • Octal number system (base 8) • Hexadecimal number system (base16)
Decimal system • We use decimal numbers everyday. • It is a base-10 system. • 10 symbols: 0,1, 2, 3, 4, 5, 6,7, 8, 9 • The position of each digit in a decimal number can be assigned a weight.
Weights 10-2 10-3 103 102 101 100 10-1 2 7 4 5 . 2 1 4 Decimal system • Most significant digit (MSD) - the digit that carries the most weight, usually the left most • Least significant digit (LSD) - the digit that carries the least weight, usually the right most • Take example: decimal number 2745.214
Binary system • Difficult to design a system that works with 10 different voltage levels • Solution is base-2 (binary) system • 2 digits/symbols: 0, 1 • Examples: 0, 1, 01, 111, 101010
2-2 2-3 23 22 21 20 2-1 1 0 1 1 . 1 0 1 Binary System • The position of each digit (bit) in a binary number can be assigned a weight. • For example: 1011.101 • 1011.101 is a binary number • 1 is a digit, 0 is a digit, 1 is a digit… weights LSB MSB
Binary System (BIT) • It takes more digits in the binary system to represent the same value in the decimal system. • Examples: 710 = 1112 1010 102 • A single binary digit is referred to as a bit. • 8 bits make a byte.
Binary System (BIT) • With N bits we have 2N discrete values. • For example, a 4-bit system can represent 24 or 16 discrete values. • The largest value is always 2N – 1. • For the 4-bit system, 24 – 1 = 1510. • The range of values for a 4-bit number is then 0 thru 15.
Hexadecimal System • Base-16 system • 16 symbols: 10 numeric digits and 6 alphabetic characters 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F • Compact way of writing binary system. • Widely used in computer and microprocessor applications.
Weights 16-2 16-3 163 162 161 160 16-1 2 A F 8 . 9 8 E Hexadecimal System • Examples: 1C16 , A8516 • The position of each digit in a hexadecimal number can be assigned a weight • For example: 2AF8.98E
Octal System • Base-8 system. • 8 digits: 0, 1, 2, 3, 4, 5, 6, 7 • Convenient way to express binary numbers and codes.
Conversion between Numbers 5 Octal (base 8) 6 9 10 Decimal (base 10) Binary (base 2) 1 2 7 8 Hexadecimal (base 16) 3 4
1. Decimal to Binary • Method 1: Decimal number binary number • Method: sum-of-weights • Method 2: Decimal whole number binary number. • Method: division-by-2 • Method 3: Decimal fraction binary number • Method: multiplication-by-2
Method 1: Sum of Weights • Step 1: Find the power of two that fulfills the following: • Nearest to the given decimal number; and • Its decimal number is less than or equal to the given decimal number. • Step 2: Subtract the power of two (from Step 1) from the given decimal number. • Step 3: If the result of the subtraction in Step 2 is 0, go to Step 4. Else, repeat Steps 1 and 2 for the result of the subtraction in Step 2. • Step 4: Write out the binary number based on all the powers of two from Step 1.
22 24 23 21 20 Weights 1 1 0 0 1 Binary number Method 1: Sum of Weights Example 1: Convert 2510 to binary Step 1: 22 = 4? No, because it is not the nearest. 23 = 8is nearer and still less than 25. 24 = 16 is the nearest and its decimal, 16 is less than 25. 25 = 32No, because its decimal number, 32 is more than 25. Step 2: the result of subtraction 25 – 16 = 9 Step 3: Repeat Step 1: the power of two which is nearest to 9 but less than 9 is 23 = 8 Repeat Step 2: the result of subtraction 9 – 8 = 1 Repeat Step 1: the power of two which is nearest to 1 and equal to 1 is 20 = 1 Repeat Step 2: the result of subtraction 1 – 1 = 0 Step 4: Write out the binary number based on all the powers of two from Step 1.
Method 2: Division-by-2 • Method 2 is used to convert only whole decimal numbers (no fraction) to binary. • Repeat the division of the decimal number with 2 until the quotient is 0. • Remainder of each division determine the binary number. First remainder represent the LSB and the last remainder is the MSB.
1 1 0 0 1 Method 2: Division-by-2 Example 1: Convert 2510 to binary Quotient Remainder LSB MSB 2510 =
Method 3: Multiplication-by-2 • Method 3 is used to convert decimal fraction only to binary. • Repeat the multiplication until the fractional part of the product are all zeros. • The binary number is determined by the first digit in the multiplication results.
Method 3: Multiplication-by-2 Example 2: Convert 0.3125 to binary Carry 0 0.3125 x 2 = 0.625 MSB LSB The binary fraction is: 1 0.625 x 2 = 1.25 . 0 1 0 1 0 0.25 x 2 = 0.50 1 0.50 x 2 = 1.00
2-2 2-3 23 22 21 20 2-1 1 0 1 1 . 1 0 1 2. Binary to Decimal • Only one method is used. That is the sum of weight. • Example 3: Convert 1011.101 to decimal =(1x23) + (0x22) + (1x21) + (1x20) + (1x2-1) + (0x2-2) + (1x2-3) = 8 + 0 + 2 + 1 + 0.5 + 0 + 0.125 = 11.62510
3. Decimal to Hexadecimal • Method used is repeated division by-16. • Repeat the division of the decimal number with 16 until the quotient is 0. • Remainder of each division determine the hex number. First remainder represent the LSB and the last remainder is the MSB.
2 8 A 65010 = Decimal to Hexadecimal Example 4: Convert 65010 to hex number Quotient Remainder (decimal) Remainder (hexadecimal) LSB MSB
4. Hexadecimal to Decimal • Only one method is used. That is the sum of weight. Example 5: Convert A8516 to decimal number 162 161 160 A 8 5 = (A x 162) + (8 x 161) + (5 x 160) = (10 x 256) + (8 x 16) + (5 x 1) = 2560 + 128 + 5 = 2693
5. Decimal to Octal • Method used is repeated division by-8. • Repeat the division of the decimal number with 8 until the quotient is 0. • Remainder of each division determine the oct number. First remainder represent the LSB and the last remainder is the MSB.
5 4 7 35910 = Decimal to Octal Example 6: Convert 35910 to octal number Quotient Remainder LSB MSB
83 82 81 80 2 3 7 4 6. Octal to Decimal • Only one method is used. That is the sum of weight. Example 7: Convert 23748 to decimal number = (2 x 83) + (3 x 82) + (7 x 81) + (4 x 80) = (2 x 512) + (3 x 64) + (7 x 8) + (4 x 1) = 1024 + 192 + 56 + 4 = 1276
1111 0001 0110 1001 0011 Binary Hexadecimal 3 F 1 6 9 7. Binary to Hexadecimal • Step 1: Break the binary number into 4-bit groups, starting from LSB. • Step 2: Replace each 4-bit with the equivalent hexadecimal number. Example 8: Convert 111111000101101001 to hex number
Hexadecimal C F 8 E 1111 1000 1110 1100 Binary 8. Hexadecimal to Binary • Step: Replace each digit of the hexadecimal number with the equivalent 4-bit binary number. Example 9: Convert CF8E16 to binary number
101 111 001 Binary Octal 5 7 1 9. Binary to Octal • Step 1: Break the binary number into 3-bit groups, starting from LSD. • Step 2: Replace each 3-bit group with the equivalent octal number. Example 10: Convert 1011110012 to octal number
7 5 2 6 Octal 101 010 110 111 Binary 10. Octal to Binary • Step: Replace each digit of the octal number with the equivalent 3-bit binary number. Example 11: Convert 75268 to binary number
Summary of Conversion Division-by-8 Octal (base 8) Sum of weight 3 bit conversion Digit-to-3 bit Division-by-2 Decimal (base 10) Binary (base 2) Sum of weight 4 bit conversion Digit-to-4 bit Hexadecimal (base 16) Division-by-16 Sum of weight