Digital Electronics One Chapter 2 Numbering Systems Week
Digital Electronics One Chapter 2 Numbering Systems Week 2
Decimal – Base 10 System • Decimal covers all the digits from 0 to 9, hence a base 10 system (10 numbers) • Decimal is broken down into exponential factors of 10 sorted into placeholders: 10, 000 1, 000 TEN-THOUSANDS PLACE THOUSANDS 104 103 100 HUNDREDS 102 10 TENTHS 101 1 ONE 100
Binary – Base 2 System • Binary is a system of numbers that encompasses the digits 0 and 1 (unlike Decimal which is 0 -9) • Since Binary has only two states, it is broken down into exponential factors of 2 28 27 26 256 128 64 25 24 32 16 23 8 22 4 21 2 20 1
Binary • Decimal to Binary ; Binary to Decimal Conversion – Base 10 to Base 2: – Two methods: Number Line vs. Divide by 2 Method – Example: convert 2210 to Base 2 • Number Line: 24 23 22 16 8 4 1 0 1 22 – 16 = 6 – 4 = 2 – 2 = 0 21 2 1 20 1 0 24 highest power of 2 that subtracted from 22 (22 -24 = 6) 23 is too high to be subtracted from 6 (23 = 8) so 0 goes in 23 column 22 can be subtracted from 6, so a 1 goes in the 22 column (6 -22 = 2) 21 can be subtracted from 2, so a 1 goes in the 21 column (2 -21 = 0) 0 is the remainder, a 0 goes into the 20 column (0 -0 = 0) Result: 1 0 1 1 02 = 2210
Binary • Decimal to Binary continued: – Divide by 2 method Start with: 2| 22 goes in evenly 11 times with no remainder 0 LSB 2|11 goes in 5 times with a remainder of 1 2|5 goes in 2 times with a remainder of 1 2|2 goes in evenly 1 time with a remainder of 0 2|1 doesn’t go into, remainder of 1 MSB – So the results from the number line and the divide by 2 method both produce 1 0 1 1 02
Binary • Binary to Decimal Conversion: • Number line is the best method of conversion – 1 1 1 0 0 1 0 12 into Base 10 – Line up the binary 1 and 0’s starting from the LSB into the powers of 2 placeholders – 29 28 27 26 25 24 23 22 21 20 – 1 1 1 0 0 1 0 1 Equates to 1 X 29 + 1 X 28 + 1 X 27 + 0 X 26 + 0 X 25 + 1 X 24 + 0 X 23 + 1 X 22 + 0 X 21 + 1 X 20 = 512 + 256 + 128 + 16 + 4 + 1 = 91710 SO 1 1 1 0 0 1 0 12 = 91710
Binary • Convert Decimal Fractions to Binary – Deals with negative powers of 2 (2 -1 2 -2 2 -3 …) – Process of separating the fractional part of the decimal number and progressively multiply it by 2 – Example: 17. 37510 (ignore the 1710 part for this example) Start with 375 (fraction part of the decimal number). This will be multiplied by 2 in the following manner: 2 -1 = 0. 5 0 2 -2 = 0. 25 1 2 -3 = 0. 125 1 0. 25 + 0. 125 = 0. 375 decimal point . |375 0|750 (375 X 2) 1|500 (750 X 2) 1|000 (500 X 2). 37510 =. 0112
Binary • Addition, Subtraction, Multiplication, and Division • Addition: 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, 1 + 1 = 0 carry 1, 1 + 1 = 1 carry 1 • Subtraction: 0 – 0 = 0, 1 – 0 = 1, 1 – 1 =0, 0 – 1 requires borrow of 102 (102 – 1 = 1) • Multiplication: 0 X 0 = 0, 0 X 1 = 0, 1 X 0 = 0, 1 X 1 = 1 • Division is a multi-stage process of subtraction
Hexadecimal – Base 16 • Hexadecimal is a system that encompasses both the 0 -9 decimal system plus adds A B C D E and F; where A=10, B=11, C=12, D=13, E=14, and F=15 (0 -F) • Expressed in powers of 16 on a number line 165 164 163 1, 048, 576 65, 536 4, 096 162 161 160 256 16 1
Hexadecimal • Binary to Hexadecimal conversion – Starting from the LSB of your binary string, put the 1’s and 0’s in groups of four – Then convert the group of four’s into its hexadecimal equivalent – Example: 1 0 0 1 1 0 1 0 1 0 12 • 0100 = 4 , 1111 = 15 = F, 0100 = 4, 1010 = A, 1101 = 13 = D • So 10011110100101011012 = 4 F 4 D 16 • Hexadecimal to Binary Conversion – Convert each individual Hex term into its Binary equivalent – Example: ACD 416 A=10102 , C=11002, D=11012, 4=01002 – 1010110101002
Hexadecimal • Hexadecimal to Decimal Conversion – Number line conversion chart with powers of 16 165 1, 048, 576 164 163 162 161 160 65, 536 4, 096 256 16 1 • Decimal to Hexadecimal Conversion – Number line conversion with powers of 16 165 164 163 162 161 160 1, 048, 576 65, 536 4, 096 256 16 1
Hexadecimal • Hexadecimal Addition – Addition follows traditional rules with the exception that if the value exceeds 15, you subtract the value from 16 and carry over a one in the next column – Example: A 3916 + CB 416 Start with the 9+4 which equals 13. Since 13 is a valid hex number, the hex equivalent of 13 is used [ D ] Then we add the 3 + B. Since B = 11 this is the same as 3 + 11 = 14. Since 14 is a valid Hex number, the Hex equivalent is used [ E ] Final add A + C. Since A = 10 and C = 12, this is the same as adding 10+12 = 22. Since 22 is too high to be represented as a hex value, subtract 16 from it and carry over a 1 in the next column. So 22 – 16 = 6, plus the 1 in the next column Result would be 16 ED 16
Hexadecimal • Hexadecimal Subtraction – Subtraction follows the traditional rules with the exception that when you need to borrow, you borrow 1610 or [ 1016 ] and add that to the value – Example: 72 A 16 – 49116 A – 1 = 9 since A = 10 2 – 9 cannot be done so we must borrow from 7 to add 16 to the 2. So we change 7 to 6 and add 16 to the 2 to make it 18. Then we subtract 18 – 9 = 9 6– 4=2 Result is 29916
Octal – Base 8 • Number system that includes digits 0 – 7 and is expressed in powers of 8. 85 32, 768 84 83 82 81 80 4096 512 64 8 1 • Use the number line to convert decimal to octal and vice versa
Octal • Octal to Binary and Binary to Octal conversion – Going Octal to Binary is as simple as translating all the octal digits into their separate binary code – Example: 6348 Binary Start with the 68 into Binary 1102 Then 38 into Binary 0112 Then 48 into Binary 1002 Result: 1100111002 • Binary to Octal conversion – Requires grouping binary into groups of 3 starting with LSB – Example: 10110100010102 010 = 2; 001 = 1; 010 = 2; 011 = 3; 001 = 1 Result: 132128
Binary Coded Decimal • Binary Coded Decimal is a system that includes all the binary digits from 0000 to 10012 • It’s a 4 bit Mod 10 system (10 active states) • It holds the same place holders as decimal system does, but digits are expressed as Binary • Example: 521 expressed as BCD Since the 5 is in the hundreds place, the 2 in the tens place, and 1 in the ones place And 5 = 0101 , 2 = 0010, and 1 = 0001, 521 would be expressed as: 0101 0010 5 2 0001 BCD 1
Binary Coded Decimal • Adding Binary Coded Decimal: – You would add BCD numbers by following the rules of binary addition – The results must be within the BCD range. If the BCD value is above 10012, then 01102 must be added to the result and a 1 carried over – Example: 0101 0110 BCD + 0110 0000 0111 BCD 01010110 + 0101 01111 0110 0000 0111 101101111101 Invalid >1011 1000 1101 not valid BCD 1 011000000111 WRONG! 1 0110 0001 carry 1 0011 carry 1 Result: 0001 1000 0011 BCD or 1183
Gray Codes • Gray Code is a system where only 1 bit can be changed in the system per clock pulse • A Binary system like 1 3 2 6 4 12 8 9 1 1001 0001 0010 0110 0100 1000 1001 0001 • To Convert Binary to Gray: Keep the state of MSB, then add the MSB bit to its next bit w/o carrying 1 0 0 02 to Gray Keep the MSB [ 1 ] then add this 1 to the 0 next to it Then that 0 is added to the 0 LSB 1+0 = 1, 0+0=0 so the result: 1100 Gray
- Slides: 18