SlideShare a Scribd company logo
1 of 42
Download to read offline
NUMBER	SYSTEMS	
ECE 301 – Digital Electronics
Dr. Xiang Chen
Electrical and Computer Engineering
Lecture #2
Spring 2019 ECE 301 - Digital Electronics 1
Topics	Covered
• Binary, Hexadecimal, and Octal number systems.
• Number system conversion
• Binary to decimal.
• Decimal to binary.
• Binary to hexadecimal.
• Hexadecimal to binary.
• Binary Codes
• 8-4-2-1 Weighted
• Binary Coded Decimal (BCD), Excess-3, Gray
• ASCII
• Parity
Spring 2019 ECE 301 - Digital Electronics 2
Assigned	Reading
• M/C: 1.2 – 1.4
Spring 2019 ECE 301 - Digital Electronics 3
NUMBER	SYSTEMS
Spring 2019 ECE 301 - Digital Electronics 4
Positional	Number	Systems
Spring 2019 ECE 301 - Digital Electronics 5
[ kn-1kn-2…k1k0 . k-1k-2…k-(m-1)k-m ]r
n-digit integer m-digit fraction
radix point radix (base)
V(K) = kn-1 x rn-1 + kn-2 x rn-2 + … + k1 x r1 + k0 x r0
+ k-1 x r-1 + k-2 x r-2 + … + k-m x r-m
The weight of each digit is implied by its position in the number.
Number	Systems
• The number systems of significance to this course are:
Spring 2019 ECE 301 - Digital Electronics 6
Number System Base Digits
Binary 2 0, 1
Octal 8 0 – 7
Decimal 10 0 – 9
Hexadecimal 16 0 – 9, A – F
Number	Systems:	Decimal
• Radix (base) = 10
• Digits: D = { 0, 1, … , 8, 9 }
• D = dn-1dn-2…d0.d-1d- 2…d-m
• D = 492.3710
• V(D) = 4 x 102
+ 9 x 101
+ 2 x 100
+ 3 x 10-1
+ 7 x 10-2
Spring 2019 ECE 301 - Digital Electronics 7
V(D) = dn-1 x 10n-1 + dn-2 x 10n-2 + … + d1 x 101 + d0 x 100
+ d-1 x 10-1 + d-2 x 10-2 + … + d-m x 10-m
integer fraction
decimal point
Number	System:	Binary
• Radix (base) = 2
• Digits: B = { 0, 1 }
• B = bn-1bn-2…b0.b-1b- 2…b-m
• B = 10110.0112
• V(B) = 1 x 24
+ 0 x 23
+ 1 x 22
+ 1 x 21
+ 0 x 20
+ 0 x 2-1
+ 1 x 2-2
+ 1 x 2-3
V(B) = 22.37510
Spring 2019 ECE 301 - Digital Electronics 8
integer fraction
binary point
V(B) = bn-1 x 2n-1 + bn-2 x 2n-2 + …
+ b1 x 21 + b0 x 20
+ b-1 x 2-1 + b-2 x 2-2 + … + b-m x 2-m
base
An n-bit integer can represent a value in the range: 0 to 2n-1.
LSbMSb
Number	Systems:		Hexadecimal
• Radix (base) = 16
• Digits: H = { 0, 1, … , 9, A, …, F }
• A = 10, B = 11, C = 12
• D = 13, E = 14, F = 15
• H = hn-1hn-2…h0.h-1h- 2…h-m
• H = B7E.3C16
• V(H) = 11 x 162
+ 7 x 161
+ 14 x 160
+ 3 x 16-1
+ 12 x 16-2
V(H) = 2942.2310
Spring 2019 ECE 301 - Digital Electronics 9
V(H) = hn-1 x 16n-1 + hn-2 x 16n-2 + … + h1 x 161 + h0 x 160
+ h-1 x 16-1 + h-2 x 16-2 + … + h-m x 16-m
integer fraction
hexadecimal point
base
Conversion:		Decimal	to	Binary
• To convert the integer part of a fixed point decimal number.
• Use repeated division.
• Conversion from decimal (r = 10) to binary (r = 2):
(DINT)10 = bn-1 x 2n-1 + bn-2 x 2n-2 + … + b1 x 21 + b0 x 20
(DINT)10 / 2 = Q0 + remainder
= Q0 + b0
(Q0) / 2 = Q1 + b1
(Q1) / 2 = Q2 + b2
...
Spring 2019 ECE 301 - Digital Electronics 10
LSb
Conversion:		Decimal	to	Binary
Spring 2019 ECE 301 - Digital Electronics 11
(125)10
125 / 2 = 62 1
62 / 2 = 31 0
31 / 2 = 15 1
15 / 2 = 7 1
7 / 2 = 3 1
3 / 2 = 1 1
1 / 2 = 0 1
= (1111101)2
MSb
LSb
Conversion:		Decimal	to	Binary
• To convert the integer part of a fixed-point decimal number.
• Alternately, use repeated subtraction.
• Conversion from decimal (r = 10) to binary (r = 2):
(DINT)10 = bn-1 x 2n-1 + bn-2 x 2n-2 + … + b1 x 21 + b0 x 20
Spring 2019 ECE 301 - Digital Electronics 12
Largest power of 2 that is less than DINT.
Conversion:		Decimal	to	Binary
Spring 2019 ECE 301 - Digital Electronics 13
(157)10
157 – 128 = 29 1 x 27
29 – 16 = 13 1 x 24
13 – 8 = 5 1 x 23
5 – 4 = 1 1 x 22
1 – 1 = 0 1 x 20
= (10011101)2
LSb
MSb
Conversion:		Decimal	to	Binary	
• To convert the fraction part of a fixed-point decimal number.
• Use repeated multiplication.
• Conversion from decimal (r = 10) to binary (r = 2):
(DFRAC)10 = b-1 x 2-1 + b-2 x 2-2 + … + b-(m-1) x 2-(m-1) + b-m x 2-m
(DFRAC)10 * 2 = b-1 + R0
R0 * 2 = b-2 + R1
R1 * 2 = b-3 + R2
…
Spring 2019 ECE 301 - Digital Electronics 14
0.6875 * 2 = 1.375 1
Conversion:		Decimal	to	Binary	
Spring 2019 ECE 301 - Digital Electronics 15
(0.6875)10
0.375 * 2 = 0.750 0
0.75 * 2 = 1.500 1
= (0.1011)2
LSb
MSb
0.5 * 2 = 1.000 1
Number	Systems:		Hexadecimal
• Hexadecimal is a useful shorthand notation for binary.
• Each hexadecimal digit corresponds to four bits.
Spring 2019 ECE 301 - Digital Electronics 16
Hexadecimal Decimal Binary
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
Hexadecimal Decimal Binary
8 8 1000
9 9 1001
A 10 1010
B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111
Conversion:		Hexadecimal	to	Binary
• Convert each hex digit to an equivalent 4-bit binary number.
• Use the 8-4-2-1 binary weighted code.
• Repeat for all digits in the hexadecimal number.
Spring 2019 ECE 301 - Digital Electronics 17
4 C 9 . 1 B 16
0100 1100 1001 0001 1011
4C9.1B16 = 0100 1100 1001 . 0001 1011 2
Conversion:		Binary	to	Hexadecimal
• Separate the binary number into 4-bit groups.
• Start at the binary point and work outwards.
• Pad with 0’s on the left (integer) and on the right (fraction).
• Convert each 4-bit group to the equivalent hex digit.
• Use the 8-4-2-1 weighted binary code.
• Repeat for all 4-bit groups in the binary number.
Spring 2019 ECE 301 - Digital Electronics 18
110 1000 1110 . 0111 101 2
6 8 E 7 A
Pad with 0’s Pad with 0’s
110 1000 1110 . 0111 101 2 = 68E.7A16
CODES
Binary codes (BCD, Excess-3, Gray, One-hot)
ASCII
Parity
Spring 2019 ECE 301 - Digital Electronics 19
Binary	Coded	Decimal	(BCD)
• Each decimal digit is represented by a 4-bit pattern (or code).
• Only 10 of the 16 patterns are used.
• Remaining 6 patterns should never occur.
• Treated as “don’t cares”.
• Weighted Code:
• Each bit position has a specific weight (8-4-2-1).
• Decimal value of each code can be determined.
• Very different from binary representation.
• Advantage: easily displayed on simple
digit-oriented (7-Segment) displays.
• Disadvantage: complex arithmetic circuits.
Spring 2019 ECE 301 - Digital Electronics 20
Decimal BCD
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
8-4-2-1 Code
Conversion:		Decimal	to	BCD
• Convert each decimal digit to its 4-bit binary code.
• Use the 8-4-2-1 binary weighted code.
• Repeat for all digits in the decimal number.
Spring 2019 ECE 301 - Digital Electronics 21
9 3 7 . 2 5 10
1001 0011 0111 0010 0101
937.2510 = 1001 0011 0111 . 0010 0101 BCD
Binary Representation: 937.2510 = 1110101001.012
Conversion:		BCD	to	Decimal
• Separate the BCD number into 4-bit groups.
• Start at the binary point and work outwards.
• Pad with 0’s on the left and on the right.
• Convert each 4-bit group to the equivalent decimal digit.
• Use the 8-4-2-1 weighted binary code.
• Repeat for all 4-bit groups in the BCD number.
Spring 2019 ECE 301 - Digital Electronics 22
0100 1001 0010 . 0101 0011 BCD
4 9 2 5 3
0100 1001 0010 . 0101 0011 BCD = 492.5310
Excess-3	Code
• Each decimal digit is represented by a 4-bit pattern (or code).
• Only 10 of the 16 patterns are used.
• Remaining 6 patterns should never occur.
• Treated as “don’t cares”.
• Based on the 8-4-2-1 weighted code.
• 8421 weighted code + 3
• Very different from binary representation.
Spring 2019 ECE 301 - Digital Electronics 23
Decimal Excess-3
0 0011
1 0100
2 0101
3 0110
4 0111
5 1000
6 1001
7 1010
8 1011
9 1100
Gray	Code
• Each decimal digit is represented by a 4-bit pattern (or code).
• Only 10 of the 16 patterns are used.
• Remaining 6 patterns should never occur.
• Treated as “don’t cares”.
• Unweighted Code:
• Bit positions do not have specific weights.
• Decimal value assigned to each pattern/code.
• Very different from binary representation.
Spring 2019 ECE 301 - Digital Electronics 24
Decimal Gray Code
0 0000
1 0001
2 0011
3 0010
4 0110
5 1110
6 1010
7 1011
8 1001
9 1000
ASCII
• American Standard Code for Information Interchange
• Commonly used for storage and transfer of alphanumeric info.
• 7-bit weighted code used to represent 128 characters.
• Used for letters, numbers, and other characters.
• An eighth bit is often used for parity.
• Any word or number can be represented using ASCII.
Spring 2019 ECE 301 - Digital Electronics 25
HeLp!
Binary:
Hexadecimal: 0x48 0x65 0x4C 0x70
0100 1000 0110 0101 0100 1100 0111 0000
ASCII is a 7-bit Code.
MSb is assumed to be 0.
ASCII	Table
Spring 2019 ECE 301 - Digital Electronics 26
Parity
• Additional bit(s) to provide error-checking capability.
• Even parity:
• Even number of 1’s in code.
• Odd parity:
• Odd number of 1’s in code.
• Each decimal digit represented
by a 5-bit pattern.
• 4 bits for the code
• 1 bit for parity (error checking).
• For example: decimal value = 6
• Even parity: 0 0110
• Odd parity: 1 0110
Spring 2019 ECE 301 - Digital Electronics 27
Decimal BCD Even Odd
0 0000 0 1
1 0001 1 0
2 0010 1 0
3 0011 0 1
4 0100 1 0
5 0101 0 1
6 0110 0 1
7 0111 1 0
8 1000 1 0
9 1001 0 1
Questions?
Spring 2019 ECE 301 - Digital Electronics 28
ADDITIONAL	SLIDES
Number Systems
Conversion
Binary Codes
Spring 2019 ECE 301 - Digital Electronics 29
Binary:		Powers	of	Two
Spring 2019 ECE 301 - Digital Electronics 30
Power of Two Decimal Value
20 1
21 2
22 4
23 8
24 16
25 32
26 64
27 128
28 256
29 512
210 1024
Conversion:		Decimal	to	Binary
Spring 2019 ECE 301 - Digital Electronics 31
(346)10
346 / 2 = 173 0
173 / 2 = 86 1
86 / 2 = 43 0
43 / 2 = 21 1
21 / 2 = 10 1
10 / 2 = 5 0
5 / 2 = 2 1
2 / 2 = 1 0
1 / 2 = 0 1
= (101011010)2
MSb
LSb
Conversion:		Decimal	to	Binary	
Spring 2019 ECE 301 - Digital Electronics 32
(0.3125)10
0.3125 * 2 = 0.625 0
0.625 * 2 = 1.250 1
0.25 * 2 = 0.500 0
0.5 * 2 = 1.000 1
= (0.0101)2
LSb
MSb
Conversion:		Decimal	to	Binary	
Spring 2019 ECE 301 - Digital Electronics 33
(0.3)10
0.3 * 2 = 0.6 0
0.6 * 2 = 1.2 1
0.2 * 2 = 0.4 0
0.4 * 2 = 0.8 0
0.8 * 2 = 1.6 1
0.6 * 2 = 1.2 1
0.2 * 2 = 0.4 0
0.4 * 2 = 0.8 0
0.8 * 2 = 1.6 1
…
MSb
= (0.0 1001)2
Binary:		Number	of	Values	and	Range
• For an N-bit unsigned binary number,
• Number of values that can be represented: 2N
• Range of values: 0 <= V(B) <= 2N – 1
Spring 2019 ECE 301 - Digital Electronics 34
N # of Values Range
4 16 0 <= V(B) <= 15
5 32 0 <= V(B) <= 31
8 256 0 <= V(B) <= 255
16 65536 0 <= V(B) <= 65535
32 232 0 <= V(B) <= 232 – 1
Number	Systems:		Octal
• Radix (base) = 8
• Digits: O = { 0, 1, … , 6, 7 }
• O = on-1on-2…o0.o-1o- 2…o-m
• O = 2374.158
• V(O) = 2 x 83
+ 3 x 82
+ 7 x 81
+ 4 x 80
+ 1 x 8-1
+ 5 x 8-2
V(O) = 1276.2010
Spring 2019 ECE 301 - Digital Electronics 35
V(O) = on-1 x 8n-1 + on-2 x 8n-2 + … + o1 x 81 + o0 x 80
+ o-1 x 8-1 + o-2 x 8-2 + … + o-m x 8-m
integer fraction
octal point
base
Number	Systems:		Octal
• Octal was a useful shorthand notation for binary.
• Each octal digit corresponds to three bits.
Spring 2019 ECE 301 - Digital Electronics 36
Octal Decimal Binary
0 0 000
1 1 001
2 2 010
3 3 011
4 4 100
5 5 101
6 6 110
7 7 111
Conversion:		Binary	to/from	Octal
• Convert the given octal numbers to binary:
101100010001.1110112
101 100 010 001 . 111 011 2 = 5421.738
1111010110101.01112
001 111 010 110 101 . 011 100 2 = 17265.348
• Convert the given binary number to octal:
341.528 = 011 100 001 . 101 010 2
Spring 2019 ECE 301 - Digital Electronics 37
Conversion:		Binary	to	Octal
• Separate the binary number into 3-bit groups.
• Start at the binary point and work outwards.
• Pad with 0’s on the left (integer) and on the right (fraction).
• Convert each 3-bit group to the equivalent octal digit.
• Use the 4-2-1 weighted binary code.
• Repeat for all 3-bit groups in the binary number.
Spring 2019 ECE 301 - Digital Electronics 38
1 111 010 110 101 . 011 1 2
1 7 2 5 3
Pad with 0’s Pad with 0’s
1111010110101 . 0111 2 = 17265.348
6 4
Conversion:		Octal	to	Binary
• Convert each octal digit to an equivalent 3-bit binary number.
• Use the 4-2-1 binary weighted code.
• Repeat for all digits in the octal number.
Spring 2019 ECE 301 - Digital Electronics 39
3 4 1 . 5 2 8
011 100 001 101 010
341.528 = 011 100 001 . 101 010 2
Number	Systems
Spring 2019 ECE 301 - Digital Electronics 40
Decimal Binary Hex Octal
00 00000 00 00
01 00001 01 01
02 00010 02 02
03 00011 03 03
04 00100 04 04
05 00101 05 05
06 00110 06 06
07 00111 07 07
08 01000 08 10
09 01001 09 11
Decimal Binary Hex Octal
10 01010 0A 12
11 01011 0B 13
12 01100 0C 14
13 01101 0D 15
14 01110 0E 16
15 01111 0F 17
16 10000 10 20
17 10001 11 21
18 10010 12 22
19 10011 13 23
Conversion:		Decimal	to	Base-r
• To convert a fixed-point decimal number to any other base:
1. Use repeated division to convert integer part.
• Divide by new base.
2. Use repeated multiplication to convert fraction part.
• Multiply by new base.
3. Combine integer and fraction parts in new base.
Spring 2019 ECE 301 - Digital Electronics 41
[ kn-1kn-2…k1k0 . k-1k-2…k-(m-1)k-m ]10
n-digit integer m-digit fraction
Binary	Codes
• Each decimal digit is represented by a 4-bit pattern (or code).
Spring 2019 ECE 301 - Digital Electronics 42
Decimal Binary-Coded Decimal Excess-3 Gray
0 0000 0011 0000
1 0001 0100 0001
2 0010 0101 0011
3 0011 0110 0010
4 0100 0111 0110
5 0101 1000 1110
6 0110 1001 1010
7 0111 1010 1011
8 1000 1011 1001
9 1001 1100 1000

More Related Content

What's hot

Notes unit 2
Notes   unit 2Notes   unit 2
Notes unit 2KamarajA5
 
Chapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemChapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemISMT College
 
Introduction to number system
Introduction to number systemIntroduction to number system
Introduction to number systemAswiniT3
 
Cse 112 number system-[id_142-15-3472]
Cse 112 number system-[id_142-15-3472]Cse 112 number system-[id_142-15-3472]
Cse 112 number system-[id_142-15-3472]Jumaed
 
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Ra'Fat Al-Msie'deen
 
Digital fundamendals r001a
Digital fundamendals r001aDigital fundamendals r001a
Digital fundamendals r001aarunachalamr16
 
Binary coded decimal r004
Binary coded decimal   r004Binary coded decimal   r004
Binary coded decimal r004arunachalamr16
 
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...Arti Parab Academics
 
Introduction of number system
Introduction of number systemIntroduction of number system
Introduction of number systemAswiniT3
 
Computer architecture data representation
Computer architecture  data representationComputer architecture  data representation
Computer architecture data representationAnil Pokhrel
 
CArcMOOC 02.02 - Encodings of numerical sets
CArcMOOC 02.02 - Encodings of numerical setsCArcMOOC 02.02 - Encodings of numerical sets
CArcMOOC 02.02 - Encodings of numerical setsAlessandro Bogliolo
 

What's hot (20)

Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Digital Design Session 2
Digital Design Session 2Digital Design Session 2
Digital Design Session 2
 
Number Systems Basic Concepts
Number Systems Basic ConceptsNumber Systems Basic Concepts
Number Systems Basic Concepts
 
Notes unit 2
Notes   unit 2Notes   unit 2
Notes unit 2
 
Chapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemChapter 2.1 introduction to number system
Chapter 2.1 introduction to number system
 
Arithmetic circuits
Arithmetic circuitsArithmetic circuits
Arithmetic circuits
 
Assembly language 2
Assembly language 2Assembly language 2
Assembly language 2
 
Introduction to number system
Introduction to number systemIntroduction to number system
Introduction to number system
 
Cse 112 number system-[id_142-15-3472]
Cse 112 number system-[id_142-15-3472]Cse 112 number system-[id_142-15-3472]
Cse 112 number system-[id_142-15-3472]
 
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
 
Data representation
Data representationData representation
Data representation
 
Digital fundamendals r001a
Digital fundamendals r001aDigital fundamendals r001a
Digital fundamendals r001a
 
Binary coded decimal r004
Binary coded decimal   r004Binary coded decimal   r004
Binary coded decimal r004
 
09 Arithmetic
09  Arithmetic09  Arithmetic
09 Arithmetic
 
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
 
Introduction of number system
Introduction of number systemIntroduction of number system
Introduction of number system
 
Digital Design Session 1
Digital Design Session 1Digital Design Session 1
Digital Design Session 1
 
Computer architecture data representation
Computer architecture  data representationComputer architecture  data representation
Computer architecture data representation
 
CArcMOOC 02.02 - Encodings of numerical sets
CArcMOOC 02.02 - Encodings of numerical setsCArcMOOC 02.02 - Encodings of numerical sets
CArcMOOC 02.02 - Encodings of numerical sets
 
Counit2
Counit2Counit2
Counit2
 

Similar to Ece 301 lecture 2 - number systems and codes

12.Representation of signed binary numbers. Binary codes - BCD code, Gray co...
12.Representation of signed binary numbers.  Binary codes - BCD code, Gray co...12.Representation of signed binary numbers.  Binary codes - BCD code, Gray co...
12.Representation of signed binary numbers. Binary codes - BCD code, Gray co...JatinJatin30
 
Digital Logic Design.pptx
Digital Logic Design.pptxDigital Logic Design.pptx
Digital Logic Design.pptxAminaZahid16
 
Unit-6 Computer Arithmetic.ppsx
Unit-6 Computer Arithmetic.ppsxUnit-6 Computer Arithmetic.ppsx
Unit-6 Computer Arithmetic.ppsxtest227270
 
Ch02_Number_system_decimal_octal_Binary_hex.ppt
Ch02_Number_system_decimal_octal_Binary_hex.pptCh02_Number_system_decimal_octal_Binary_hex.ppt
Ch02_Number_system_decimal_octal_Binary_hex.pptgprtpo
 
digital%20electronics.pptx
digital%20electronics.pptxdigital%20electronics.pptx
digital%20electronics.pptxansariparveen06
 
unit-i-number-systems.pdf
unit-i-number-systems.pdfunit-i-number-systems.pdf
unit-i-number-systems.pdfRameshK531901
 
digital-systems-and-binary-numbers1.pptx
digital-systems-and-binary-numbers1.pptxdigital-systems-and-binary-numbers1.pptx
digital-systems-and-binary-numbers1.pptxRameshK531901
 
Chapter 5: Cominational Logic with MSI and LSI
Chapter 5: Cominational Logic with MSI and LSIChapter 5: Cominational Logic with MSI and LSI
Chapter 5: Cominational Logic with MSI and LSIEr. Nawaraj Bhandari
 
DIGITAL ELECTRONICS
DIGITAL ELECTRONICSDIGITAL ELECTRONICS
DIGITAL ELECTRONICSSYEDJAMAESHA
 
Digital Electronics Notes
Digital Electronics Notes Digital Electronics Notes
Digital Electronics Notes Srikrishna Thota
 
Lecture5 Chapter4- Design Decimal Adder and Binary Multiplier Circuits.pdf
Lecture5 Chapter4- Design Decimal Adder and Binary Multiplier Circuits.pdfLecture5 Chapter4- Design Decimal Adder and Binary Multiplier Circuits.pdf
Lecture5 Chapter4- Design Decimal Adder and Binary Multiplier Circuits.pdfUmerKhan147799
 

Similar to Ece 301 lecture 2 - number systems and codes (20)

12.Representation of signed binary numbers. Binary codes - BCD code, Gray co...
12.Representation of signed binary numbers.  Binary codes - BCD code, Gray co...12.Representation of signed binary numbers.  Binary codes - BCD code, Gray co...
12.Representation of signed binary numbers. Binary codes - BCD code, Gray co...
 
Digital Logic Design.pptx
Digital Logic Design.pptxDigital Logic Design.pptx
Digital Logic Design.pptx
 
Unit-6 Computer Arithmetic.ppsx
Unit-6 Computer Arithmetic.ppsxUnit-6 Computer Arithmetic.ppsx
Unit-6 Computer Arithmetic.ppsx
 
Number systems ppt
Number systems pptNumber systems ppt
Number systems ppt
 
Numbersystemsppt 181023140730
Numbersystemsppt 181023140730Numbersystemsppt 181023140730
Numbersystemsppt 181023140730
 
Ch02_Number_system_decimal_octal_Binary_hex.ppt
Ch02_Number_system_decimal_octal_Binary_hex.pptCh02_Number_system_decimal_octal_Binary_hex.ppt
Ch02_Number_system_decimal_octal_Binary_hex.ppt
 
digital%20electronics.pptx
digital%20electronics.pptxdigital%20electronics.pptx
digital%20electronics.pptx
 
DESIGN OF COMBINATIONAL LOGIC
DESIGN OF COMBINATIONAL LOGICDESIGN OF COMBINATIONAL LOGIC
DESIGN OF COMBINATIONAL LOGIC
 
unit-i-number-systems.pdf
unit-i-number-systems.pdfunit-i-number-systems.pdf
unit-i-number-systems.pdf
 
Unit-1.pptx
Unit-1.pptxUnit-1.pptx
Unit-1.pptx
 
digital-systems-and-binary-numbers1.pptx
digital-systems-and-binary-numbers1.pptxdigital-systems-and-binary-numbers1.pptx
digital-systems-and-binary-numbers1.pptx
 
Lec 02
Lec 02Lec 02
Lec 02
 
Digital logic design part1
Digital logic design part1Digital logic design part1
Digital logic design part1
 
Chapter 5: Cominational Logic with MSI and LSI
Chapter 5: Cominational Logic with MSI and LSIChapter 5: Cominational Logic with MSI and LSI
Chapter 5: Cominational Logic with MSI and LSI
 
DIGITAL ELECTRONICS
DIGITAL ELECTRONICSDIGITAL ELECTRONICS
DIGITAL ELECTRONICS
 
Digital Electronics Notes
Digital Electronics Notes Digital Electronics Notes
Digital Electronics Notes
 
Number Systems.pptx
Number Systems.pptxNumber Systems.pptx
Number Systems.pptx
 
Lecture5 Chapter4- Design Decimal Adder and Binary Multiplier Circuits.pdf
Lecture5 Chapter4- Design Decimal Adder and Binary Multiplier Circuits.pdfLecture5 Chapter4- Design Decimal Adder and Binary Multiplier Circuits.pdf
Lecture5 Chapter4- Design Decimal Adder and Binary Multiplier Circuits.pdf
 
Numbering Systems
Numbering SystemsNumbering Systems
Numbering Systems
 
Chapter02.pdf
Chapter02.pdfChapter02.pdf
Chapter02.pdf
 

Recently uploaded

Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligencemahaffeycheryld
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...josephjonse
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfEr.Sonali Nasikkar
 
AI in Healthcare Innovative use cases and applications.pdf
AI in Healthcare Innovative use cases and applications.pdfAI in Healthcare Innovative use cases and applications.pdf
AI in Healthcare Innovative use cases and applications.pdfmahaffeycheryld
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualBalamuruganV28
 
Basics of Relay for Engineering Students
Basics of Relay for Engineering StudentsBasics of Relay for Engineering Students
Basics of Relay for Engineering Studentskannan348865
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...archanaece3
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxMustafa Ahmed
 
Filters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsFilters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsMathias Magdowski
 
Diploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfDiploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfJNTUA
 
Introduction to Artificial Intelligence and History of AI
Introduction to Artificial Intelligence and History of AIIntroduction to Artificial Intelligence and History of AI
Introduction to Artificial Intelligence and History of AISheetal Jain
 
Online crime reporting system project.pdf
Online crime reporting system project.pdfOnline crime reporting system project.pdf
Online crime reporting system project.pdfKamal Acharya
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdfAlexander Litvinenko
 
21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological universityMohd Saifudeen
 
Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2T.D. Shashikala
 
analog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptxanalog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptxKarpagam Institute of Teechnology
 
Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1T.D. Shashikala
 
Piping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdfPiping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdfAshrafRagab14
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsVIEW
 
Linux Systems Programming: Semaphores, Shared Memory, and Message Queues
Linux Systems Programming: Semaphores, Shared Memory, and Message QueuesLinux Systems Programming: Semaphores, Shared Memory, and Message Queues
Linux Systems Programming: Semaphores, Shared Memory, and Message QueuesRashidFaridChishti
 

Recently uploaded (20)

Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligence
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
 
AI in Healthcare Innovative use cases and applications.pdf
AI in Healthcare Innovative use cases and applications.pdfAI in Healthcare Innovative use cases and applications.pdf
AI in Healthcare Innovative use cases and applications.pdf
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
 
Basics of Relay for Engineering Students
Basics of Relay for Engineering StudentsBasics of Relay for Engineering Students
Basics of Relay for Engineering Students
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
Filters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsFilters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility Applications
 
Diploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfDiploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdf
 
Introduction to Artificial Intelligence and History of AI
Introduction to Artificial Intelligence and History of AIIntroduction to Artificial Intelligence and History of AI
Introduction to Artificial Intelligence and History of AI
 
Online crime reporting system project.pdf
Online crime reporting system project.pdfOnline crime reporting system project.pdf
Online crime reporting system project.pdf
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
 
21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university
 
Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2
 
analog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptxanalog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptx
 
Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1
 
Piping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdfPiping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdf
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, Functions
 
Linux Systems Programming: Semaphores, Shared Memory, and Message Queues
Linux Systems Programming: Semaphores, Shared Memory, and Message QueuesLinux Systems Programming: Semaphores, Shared Memory, and Message Queues
Linux Systems Programming: Semaphores, Shared Memory, and Message Queues
 

Ece 301 lecture 2 - number systems and codes

  • 1. NUMBER SYSTEMS ECE 301 – Digital Electronics Dr. Xiang Chen Electrical and Computer Engineering Lecture #2 Spring 2019 ECE 301 - Digital Electronics 1
  • 2. Topics Covered • Binary, Hexadecimal, and Octal number systems. • Number system conversion • Binary to decimal. • Decimal to binary. • Binary to hexadecimal. • Hexadecimal to binary. • Binary Codes • 8-4-2-1 Weighted • Binary Coded Decimal (BCD), Excess-3, Gray • ASCII • Parity Spring 2019 ECE 301 - Digital Electronics 2
  • 3. Assigned Reading • M/C: 1.2 – 1.4 Spring 2019 ECE 301 - Digital Electronics 3
  • 4. NUMBER SYSTEMS Spring 2019 ECE 301 - Digital Electronics 4
  • 5. Positional Number Systems Spring 2019 ECE 301 - Digital Electronics 5 [ kn-1kn-2…k1k0 . k-1k-2…k-(m-1)k-m ]r n-digit integer m-digit fraction radix point radix (base) V(K) = kn-1 x rn-1 + kn-2 x rn-2 + … + k1 x r1 + k0 x r0 + k-1 x r-1 + k-2 x r-2 + … + k-m x r-m The weight of each digit is implied by its position in the number.
  • 6. Number Systems • The number systems of significance to this course are: Spring 2019 ECE 301 - Digital Electronics 6 Number System Base Digits Binary 2 0, 1 Octal 8 0 – 7 Decimal 10 0 – 9 Hexadecimal 16 0 – 9, A – F
  • 7. Number Systems: Decimal • Radix (base) = 10 • Digits: D = { 0, 1, … , 8, 9 } • D = dn-1dn-2…d0.d-1d- 2…d-m • D = 492.3710 • V(D) = 4 x 102 + 9 x 101 + 2 x 100 + 3 x 10-1 + 7 x 10-2 Spring 2019 ECE 301 - Digital Electronics 7 V(D) = dn-1 x 10n-1 + dn-2 x 10n-2 + … + d1 x 101 + d0 x 100 + d-1 x 10-1 + d-2 x 10-2 + … + d-m x 10-m integer fraction decimal point
  • 8. Number System: Binary • Radix (base) = 2 • Digits: B = { 0, 1 } • B = bn-1bn-2…b0.b-1b- 2…b-m • B = 10110.0112 • V(B) = 1 x 24 + 0 x 23 + 1 x 22 + 1 x 21 + 0 x 20 + 0 x 2-1 + 1 x 2-2 + 1 x 2-3 V(B) = 22.37510 Spring 2019 ECE 301 - Digital Electronics 8 integer fraction binary point V(B) = bn-1 x 2n-1 + bn-2 x 2n-2 + … + b1 x 21 + b0 x 20 + b-1 x 2-1 + b-2 x 2-2 + … + b-m x 2-m base An n-bit integer can represent a value in the range: 0 to 2n-1. LSbMSb
  • 9. Number Systems: Hexadecimal • Radix (base) = 16 • Digits: H = { 0, 1, … , 9, A, …, F } • A = 10, B = 11, C = 12 • D = 13, E = 14, F = 15 • H = hn-1hn-2…h0.h-1h- 2…h-m • H = B7E.3C16 • V(H) = 11 x 162 + 7 x 161 + 14 x 160 + 3 x 16-1 + 12 x 16-2 V(H) = 2942.2310 Spring 2019 ECE 301 - Digital Electronics 9 V(H) = hn-1 x 16n-1 + hn-2 x 16n-2 + … + h1 x 161 + h0 x 160 + h-1 x 16-1 + h-2 x 16-2 + … + h-m x 16-m integer fraction hexadecimal point base
  • 10. Conversion: Decimal to Binary • To convert the integer part of a fixed point decimal number. • Use repeated division. • Conversion from decimal (r = 10) to binary (r = 2): (DINT)10 = bn-1 x 2n-1 + bn-2 x 2n-2 + … + b1 x 21 + b0 x 20 (DINT)10 / 2 = Q0 + remainder = Q0 + b0 (Q0) / 2 = Q1 + b1 (Q1) / 2 = Q2 + b2 ... Spring 2019 ECE 301 - Digital Electronics 10 LSb
  • 11. Conversion: Decimal to Binary Spring 2019 ECE 301 - Digital Electronics 11 (125)10 125 / 2 = 62 1 62 / 2 = 31 0 31 / 2 = 15 1 15 / 2 = 7 1 7 / 2 = 3 1 3 / 2 = 1 1 1 / 2 = 0 1 = (1111101)2 MSb LSb
  • 12. Conversion: Decimal to Binary • To convert the integer part of a fixed-point decimal number. • Alternately, use repeated subtraction. • Conversion from decimal (r = 10) to binary (r = 2): (DINT)10 = bn-1 x 2n-1 + bn-2 x 2n-2 + … + b1 x 21 + b0 x 20 Spring 2019 ECE 301 - Digital Electronics 12 Largest power of 2 that is less than DINT.
  • 13. Conversion: Decimal to Binary Spring 2019 ECE 301 - Digital Electronics 13 (157)10 157 – 128 = 29 1 x 27 29 – 16 = 13 1 x 24 13 – 8 = 5 1 x 23 5 – 4 = 1 1 x 22 1 – 1 = 0 1 x 20 = (10011101)2 LSb MSb
  • 14. Conversion: Decimal to Binary • To convert the fraction part of a fixed-point decimal number. • Use repeated multiplication. • Conversion from decimal (r = 10) to binary (r = 2): (DFRAC)10 = b-1 x 2-1 + b-2 x 2-2 + … + b-(m-1) x 2-(m-1) + b-m x 2-m (DFRAC)10 * 2 = b-1 + R0 R0 * 2 = b-2 + R1 R1 * 2 = b-3 + R2 … Spring 2019 ECE 301 - Digital Electronics 14
  • 15. 0.6875 * 2 = 1.375 1 Conversion: Decimal to Binary Spring 2019 ECE 301 - Digital Electronics 15 (0.6875)10 0.375 * 2 = 0.750 0 0.75 * 2 = 1.500 1 = (0.1011)2 LSb MSb 0.5 * 2 = 1.000 1
  • 16. Number Systems: Hexadecimal • Hexadecimal is a useful shorthand notation for binary. • Each hexadecimal digit corresponds to four bits. Spring 2019 ECE 301 - Digital Electronics 16 Hexadecimal Decimal Binary 0 0 0000 1 1 0001 2 2 0010 3 3 0011 4 4 0100 5 5 0101 6 6 0110 7 7 0111 Hexadecimal Decimal Binary 8 8 1000 9 9 1001 A 10 1010 B 11 1011 C 12 1100 D 13 1101 E 14 1110 F 15 1111
  • 17. Conversion: Hexadecimal to Binary • Convert each hex digit to an equivalent 4-bit binary number. • Use the 8-4-2-1 binary weighted code. • Repeat for all digits in the hexadecimal number. Spring 2019 ECE 301 - Digital Electronics 17 4 C 9 . 1 B 16 0100 1100 1001 0001 1011 4C9.1B16 = 0100 1100 1001 . 0001 1011 2
  • 18. Conversion: Binary to Hexadecimal • Separate the binary number into 4-bit groups. • Start at the binary point and work outwards. • Pad with 0’s on the left (integer) and on the right (fraction). • Convert each 4-bit group to the equivalent hex digit. • Use the 8-4-2-1 weighted binary code. • Repeat for all 4-bit groups in the binary number. Spring 2019 ECE 301 - Digital Electronics 18 110 1000 1110 . 0111 101 2 6 8 E 7 A Pad with 0’s Pad with 0’s 110 1000 1110 . 0111 101 2 = 68E.7A16
  • 19. CODES Binary codes (BCD, Excess-3, Gray, One-hot) ASCII Parity Spring 2019 ECE 301 - Digital Electronics 19
  • 20. Binary Coded Decimal (BCD) • Each decimal digit is represented by a 4-bit pattern (or code). • Only 10 of the 16 patterns are used. • Remaining 6 patterns should never occur. • Treated as “don’t cares”. • Weighted Code: • Each bit position has a specific weight (8-4-2-1). • Decimal value of each code can be determined. • Very different from binary representation. • Advantage: easily displayed on simple digit-oriented (7-Segment) displays. • Disadvantage: complex arithmetic circuits. Spring 2019 ECE 301 - Digital Electronics 20 Decimal BCD 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 8-4-2-1 Code
  • 21. Conversion: Decimal to BCD • Convert each decimal digit to its 4-bit binary code. • Use the 8-4-2-1 binary weighted code. • Repeat for all digits in the decimal number. Spring 2019 ECE 301 - Digital Electronics 21 9 3 7 . 2 5 10 1001 0011 0111 0010 0101 937.2510 = 1001 0011 0111 . 0010 0101 BCD Binary Representation: 937.2510 = 1110101001.012
  • 22. Conversion: BCD to Decimal • Separate the BCD number into 4-bit groups. • Start at the binary point and work outwards. • Pad with 0’s on the left and on the right. • Convert each 4-bit group to the equivalent decimal digit. • Use the 8-4-2-1 weighted binary code. • Repeat for all 4-bit groups in the BCD number. Spring 2019 ECE 301 - Digital Electronics 22 0100 1001 0010 . 0101 0011 BCD 4 9 2 5 3 0100 1001 0010 . 0101 0011 BCD = 492.5310
  • 23. Excess-3 Code • Each decimal digit is represented by a 4-bit pattern (or code). • Only 10 of the 16 patterns are used. • Remaining 6 patterns should never occur. • Treated as “don’t cares”. • Based on the 8-4-2-1 weighted code. • 8421 weighted code + 3 • Very different from binary representation. Spring 2019 ECE 301 - Digital Electronics 23 Decimal Excess-3 0 0011 1 0100 2 0101 3 0110 4 0111 5 1000 6 1001 7 1010 8 1011 9 1100
  • 24. Gray Code • Each decimal digit is represented by a 4-bit pattern (or code). • Only 10 of the 16 patterns are used. • Remaining 6 patterns should never occur. • Treated as “don’t cares”. • Unweighted Code: • Bit positions do not have specific weights. • Decimal value assigned to each pattern/code. • Very different from binary representation. Spring 2019 ECE 301 - Digital Electronics 24 Decimal Gray Code 0 0000 1 0001 2 0011 3 0010 4 0110 5 1110 6 1010 7 1011 8 1001 9 1000
  • 25. ASCII • American Standard Code for Information Interchange • Commonly used for storage and transfer of alphanumeric info. • 7-bit weighted code used to represent 128 characters. • Used for letters, numbers, and other characters. • An eighth bit is often used for parity. • Any word or number can be represented using ASCII. Spring 2019 ECE 301 - Digital Electronics 25 HeLp! Binary: Hexadecimal: 0x48 0x65 0x4C 0x70 0100 1000 0110 0101 0100 1100 0111 0000 ASCII is a 7-bit Code. MSb is assumed to be 0.
  • 26. ASCII Table Spring 2019 ECE 301 - Digital Electronics 26
  • 27. Parity • Additional bit(s) to provide error-checking capability. • Even parity: • Even number of 1’s in code. • Odd parity: • Odd number of 1’s in code. • Each decimal digit represented by a 5-bit pattern. • 4 bits for the code • 1 bit for parity (error checking). • For example: decimal value = 6 • Even parity: 0 0110 • Odd parity: 1 0110 Spring 2019 ECE 301 - Digital Electronics 27 Decimal BCD Even Odd 0 0000 0 1 1 0001 1 0 2 0010 1 0 3 0011 0 1 4 0100 1 0 5 0101 0 1 6 0110 0 1 7 0111 1 0 8 1000 1 0 9 1001 0 1
  • 28. Questions? Spring 2019 ECE 301 - Digital Electronics 28
  • 30. Binary: Powers of Two Spring 2019 ECE 301 - Digital Electronics 30 Power of Two Decimal Value 20 1 21 2 22 4 23 8 24 16 25 32 26 64 27 128 28 256 29 512 210 1024
  • 31. Conversion: Decimal to Binary Spring 2019 ECE 301 - Digital Electronics 31 (346)10 346 / 2 = 173 0 173 / 2 = 86 1 86 / 2 = 43 0 43 / 2 = 21 1 21 / 2 = 10 1 10 / 2 = 5 0 5 / 2 = 2 1 2 / 2 = 1 0 1 / 2 = 0 1 = (101011010)2 MSb LSb
  • 32. Conversion: Decimal to Binary Spring 2019 ECE 301 - Digital Electronics 32 (0.3125)10 0.3125 * 2 = 0.625 0 0.625 * 2 = 1.250 1 0.25 * 2 = 0.500 0 0.5 * 2 = 1.000 1 = (0.0101)2 LSb MSb
  • 33. Conversion: Decimal to Binary Spring 2019 ECE 301 - Digital Electronics 33 (0.3)10 0.3 * 2 = 0.6 0 0.6 * 2 = 1.2 1 0.2 * 2 = 0.4 0 0.4 * 2 = 0.8 0 0.8 * 2 = 1.6 1 0.6 * 2 = 1.2 1 0.2 * 2 = 0.4 0 0.4 * 2 = 0.8 0 0.8 * 2 = 1.6 1 … MSb = (0.0 1001)2
  • 34. Binary: Number of Values and Range • For an N-bit unsigned binary number, • Number of values that can be represented: 2N • Range of values: 0 <= V(B) <= 2N – 1 Spring 2019 ECE 301 - Digital Electronics 34 N # of Values Range 4 16 0 <= V(B) <= 15 5 32 0 <= V(B) <= 31 8 256 0 <= V(B) <= 255 16 65536 0 <= V(B) <= 65535 32 232 0 <= V(B) <= 232 – 1
  • 35. Number Systems: Octal • Radix (base) = 8 • Digits: O = { 0, 1, … , 6, 7 } • O = on-1on-2…o0.o-1o- 2…o-m • O = 2374.158 • V(O) = 2 x 83 + 3 x 82 + 7 x 81 + 4 x 80 + 1 x 8-1 + 5 x 8-2 V(O) = 1276.2010 Spring 2019 ECE 301 - Digital Electronics 35 V(O) = on-1 x 8n-1 + on-2 x 8n-2 + … + o1 x 81 + o0 x 80 + o-1 x 8-1 + o-2 x 8-2 + … + o-m x 8-m integer fraction octal point base
  • 36. Number Systems: Octal • Octal was a useful shorthand notation for binary. • Each octal digit corresponds to three bits. Spring 2019 ECE 301 - Digital Electronics 36 Octal Decimal Binary 0 0 000 1 1 001 2 2 010 3 3 011 4 4 100 5 5 101 6 6 110 7 7 111
  • 37. Conversion: Binary to/from Octal • Convert the given octal numbers to binary: 101100010001.1110112 101 100 010 001 . 111 011 2 = 5421.738 1111010110101.01112 001 111 010 110 101 . 011 100 2 = 17265.348 • Convert the given binary number to octal: 341.528 = 011 100 001 . 101 010 2 Spring 2019 ECE 301 - Digital Electronics 37
  • 38. Conversion: Binary to Octal • Separate the binary number into 3-bit groups. • Start at the binary point and work outwards. • Pad with 0’s on the left (integer) and on the right (fraction). • Convert each 3-bit group to the equivalent octal digit. • Use the 4-2-1 weighted binary code. • Repeat for all 3-bit groups in the binary number. Spring 2019 ECE 301 - Digital Electronics 38 1 111 010 110 101 . 011 1 2 1 7 2 5 3 Pad with 0’s Pad with 0’s 1111010110101 . 0111 2 = 17265.348 6 4
  • 39. Conversion: Octal to Binary • Convert each octal digit to an equivalent 3-bit binary number. • Use the 4-2-1 binary weighted code. • Repeat for all digits in the octal number. Spring 2019 ECE 301 - Digital Electronics 39 3 4 1 . 5 2 8 011 100 001 101 010 341.528 = 011 100 001 . 101 010 2
  • 40. Number Systems Spring 2019 ECE 301 - Digital Electronics 40 Decimal Binary Hex Octal 00 00000 00 00 01 00001 01 01 02 00010 02 02 03 00011 03 03 04 00100 04 04 05 00101 05 05 06 00110 06 06 07 00111 07 07 08 01000 08 10 09 01001 09 11 Decimal Binary Hex Octal 10 01010 0A 12 11 01011 0B 13 12 01100 0C 14 13 01101 0D 15 14 01110 0E 16 15 01111 0F 17 16 10000 10 20 17 10001 11 21 18 10010 12 22 19 10011 13 23
  • 41. Conversion: Decimal to Base-r • To convert a fixed-point decimal number to any other base: 1. Use repeated division to convert integer part. • Divide by new base. 2. Use repeated multiplication to convert fraction part. • Multiply by new base. 3. Combine integer and fraction parts in new base. Spring 2019 ECE 301 - Digital Electronics 41 [ kn-1kn-2…k1k0 . k-1k-2…k-(m-1)k-m ]10 n-digit integer m-digit fraction
  • 42. Binary Codes • Each decimal digit is represented by a 4-bit pattern (or code). Spring 2019 ECE 301 - Digital Electronics 42 Decimal Binary-Coded Decimal Excess-3 Gray 0 0000 0011 0000 1 0001 0100 0001 2 0010 0101 0011 3 0011 0110 0010 4 0100 0111 0110 5 0101 1000 1110 6 0110 1001 1010 7 0111 1010 1011 8 1000 1011 1001 9 1001 1100 1000