SlideShare a Scribd company logo
1 of 28
TOPIC: Representation of binary numbers
and
Binary Codes
Department of Electronics and Communication Engineering
Chitkara University, Punjab, India
Basic Electronics (22EC001) 1
Representation of binary numbers
Basic Electronics (22EC001) 2
Unsigned Numbers
• don’t have any sign
• contain only magnitude of the number.
Example-1: Represent decimal number 92 in unsigned binary number.
(92)10
= (1011100)2
Basic Electronics (22EC001) 3
Unsigned Numbers
Example-2: Find range of 6 bit unsigned binary
numbers. Also, find minimum and maximum value in
this range.
Sol: Since, range of unsigned binary number is from 0
to (2n-1). Therefore, range of 6 bit unsigned binary
number is from 0 to (26-1) which is equal from
minimum value 0 (i.e., 000000) to maximum value 63
(i.e., 111111).
Basic Electronics (22EC001) 4
Signed Numbers
• Unsigned representation can be used for positive integers
• How about negative integers?
– Everything must be represented in binary numbers
– Computers cannot use – or + signs
Signed numbers:
• contain sign flag
• contains both sign bit and magnitude of a number
• this representation distinguish positive and negative numbers
• For negative numbers the sign bit is always 1, and for positive numbers it
is 0 in these three systems
Basic Electronics (22EC001) 5
Representation of signed numbers
There are two ways of representing negative binary numbers:
1. Sign Magnitude form
2. Complement Method
- 1’s Complement form
- 2’s Complement form
• Advantage of using complement method for subtraction is
reduction in hardware.
• Instead of having separate circuits for addition and
subtraction, only addition circuits are needed.
Basic Electronics (22EC001) 6
Sign-Magnitude form
• For n bit binary number, 1 bit is reserved for sign symbol
• The leftmost bit is the sign bit (0 is + and 1 is - ) and the
remaining bits hold the absolute magnitude of the number
• For 8 bits, we can represent the signed integers –127 to +127
• How about for N bits? -(2n-1-1)to +(2n-1 -1)
• Examples
• -47 = 1 0 1 0 1 1 1 1
• 47 = 0 0 1 0 1 1 1 1
Basic Electronics (22EC001) 7
1’s Complement form
• Replace each 1 by 0 and each 0 by 1
• Example (-6)
– First represent 6 in binary format (00000110)
– Then replace (11111001)
Basic Electronics (22EC001) 8
2’s Complement form
• Find one’s complement
• Add 1
• Example (-6)
– First represent 6 in binary format (00000110)
– One’s complement (11111001)
– Two’s complement (11111010)
Basic Electronics (22EC001) 9
Handy Trick: Leave all of the least significant 0’s and first 1
unchanged, and then “flip” the bits for all other digits.
Eg: 01010100100 -> 10101011100
1’s and 2’s complements
• 1’s complement of 10111001
– 11111111 – 10111001 = 01000110
– Simply replace 1’s and 0’s
• 1’s complement of 10100010
– 01011101
• 2’s complement of 10111001
– 01000110 + 1 = 01000111
– Add 1 to 1’s complement
• 2’s complement of 10100010
– 01011101 + 1 = 01011110
Basic Electronics (22EC001) 10
NOTE
• “Humans” normally use sign-magnitude
representation for signed numbers
– Eg: Positive numbers: +N or N
– Negative numbers: -N
• “Computers” generally use two’s-complement
representation for signed numbers
– First bit still indicates positive or negative.
– If the number is negative, take 2’s complement to
determine its magnitude
Basic Electronics (22EC001) 11
BINARY CODES
Classification of Binary Codes:
• BCD code
• Excess three code
• Gray code
Basic Electronics (22EC001) 12
Human Perception
• We naturally live in a base 10 environment
• Computer exist in a base 2 environment
• So give the computer/digital system the task of doing
the conversions for us.
13
Basic Electronics (22EC001)
Binary Codes
14
 A binary code represents text, computer processor
instructions, or any other data using a two-symbol
system.
The two-symbol system used is often "0" and "1"
from the binary number system.
 The binary code assigns a pattern of binary digits,
also known as bits, to each character, instruction, etc.
Basic Electronics (22EC001)
Classification of Binary Codes
Basic Electronics (22EC001) 15
Defination of BCD..Binary Coded
Decimal
•Binary coded decimal (BCD) is a system of writing numbers that
assigns a four-digit binary code to each digit 0 through 9 in a decimal
(base-10) numeral.
• The four-bit BCD code for any particular single base-10 digit is its
representation in binary notation, as follows:
0 = 0000
1 = 0001
2 = 0010
3 = 0011
4 = 0100
5 = 0101
6 = 0110
Basic Electronics (22EC001) 16
 7 = 0111
 8 = 1000
 9 = 1001
Numbers larger than 9, having two or more digits in the decimal
system, are expressed digit by digit. For example, the BCD
rendition of the base-10 number 1895 is
1 8 9 5
0001 1000 1001 0101
Basic Electronics (22EC001) 17
Why BCD is Used...
• It is easy to encode and decode decimals into BCD and
vice versa. • It is also simple to implement a hardware
algorithm for the BCD converter.
• It is very useful in digital systems whenever decimal
information is given eitheras inputs or displayed as
outputs.
• Digital voltmeters, frequency converters and digital
clocks all use BCD as they display output information in
decimal
Basic Electronics (22EC001) 18
8421 BCD Code
• Valid BCD code are : 0000 to 1001
• Invalid BCD code are :1010 to 1111
Example:
Decimal number 4926 4 9 2 6
BCD coded number 0100 1001 0010 0110
Basic Electronics (22EC001) 19
Contd.
Convert the BCD coded number 1000 0111 0001
into decimal.
BCD Coded Number 1000 0111 0001
Decimal Number 8 7 1
Basic Electronics (22EC001) 20
Convert the decimal number 350 to its
BCD equivalent.
Decimal Number 3 5 0
BCD Coded Number 0011 0101 0000
Contd.
Basic Electronics (22EC001) 21
Excess 3 Code
• Add 3 to each digit of decimal and convert it to 4-bit binary form.
• Valid excess-3 code : 0011 to 1100
• Invalid excess-3 code : [0000 to 0010] and [1101 to 1111]
Decimal Binary +3 Excess-3
0 0000 0011 0011
1 0001 0011 0100
2 0010 0011 0101
3 0011 0011 0110
4 0100 0011 0111
5 0101 0011 1000
6 0110 0011 1001
7 0111 0011 1010
8 1000 0011 1011
9 1001 0011 1100
Decimal 3 5 9
Sample Problem:
Excess-3 0110 1000 1100
Basic Electronics (22EC001) 22
Gray Code
• The Gray code’s most important
characteristic is that only one
digit changes as you increment or
decrement the count. (unit
distance code)
• The Gray code is NOT a BCD
code.
Decimal Gray code
0 00000
1 00001
2 00011
3 00010
4 00110
5 00111
6 00101
7 00100
8 01100
9 01101
10 01111
11 01110
12 01010
13 01011
14 01001
15 01000
16 11000
Basic Electronics (22EC001) 23
Binary to Gray Code Conversion
• The MSB in the Gray code is the same as corresponding MSB in the binary
number.
• Going from left to right, add each adjacent pair of binary code bits to get the
next Gray code bit. Discard carries.
• Example 1:
• Example 2:
Basic Electronics (22EC001) 24
Activity 1:
Convert the following binary codes to gray codes:
1. 10010111
2. 10001001
3. 01101010
Convert the following to Gray codes:
4. (527)8 - 1111 11100
5. (3A7)16 - 0
010 0111 0100
Basic Electronics (22EC001) 25
Gray to Binary Conversion
• The MSB in the Binary code is the same as corresponding MSB in the Gray
number.
• Going from bottom to top, add each pair of gray code bits to get the next
binary code bit. Discard carries.
• Example 1:
• Example 2:
Basic Electronics (22EC001) 26
Activity 2:
Convert the following gray codes to binary codes:
1. 11001100
10001000
1. 00110011
2. 00100010
3. 11111000
4. 10101111
11111000
10101111
11111000
Basic Electronics (22EC001) 27
Thank You
Basic Electronics (22EC001) 28

More Related Content

What's hot (20)

Digital logic design part1
Digital logic design part1Digital logic design part1
Digital logic design part1
 
Digital and logic designs presentation
Digital and logic designs presentationDigital and logic designs presentation
Digital and logic designs presentation
 
Digital electronics
Digital electronicsDigital electronics
Digital electronics
 
Chapter 6 register
Chapter 6 registerChapter 6 register
Chapter 6 register
 
Signed Binary Numbers
Signed Binary NumbersSigned Binary Numbers
Signed Binary Numbers
 
COUNTERS(Synchronous & Asynchronous)
COUNTERS(Synchronous & Asynchronous)COUNTERS(Synchronous & Asynchronous)
COUNTERS(Synchronous & Asynchronous)
 
Encoder.pptx
Encoder.pptxEncoder.pptx
Encoder.pptx
 
Encoders
EncodersEncoders
Encoders
 
Decoder Full Presentation
Decoder Full Presentation Decoder Full Presentation
Decoder Full Presentation
 
decoder and encoder
 decoder and encoder decoder and encoder
decoder and encoder
 
Encoder
EncoderEncoder
Encoder
 
8251 USART
8251 USART8251 USART
8251 USART
 
Bcd
BcdBcd
Bcd
 
Encoder & Decoder
Encoder & DecoderEncoder & Decoder
Encoder & Decoder
 
Encoders and decoders
Encoders and decodersEncoders and decoders
Encoders and decoders
 
Shift Registers
Shift RegistersShift Registers
Shift Registers
 
Logic gate
Logic gateLogic gate
Logic gate
 
Multiplexer and DeMultiplexer
Multiplexer and DeMultiplexerMultiplexer and DeMultiplexer
Multiplexer and DeMultiplexer
 
Flip flops and registers
Flip flops and registersFlip flops and registers
Flip flops and registers
 
Digital electronics logic families
Digital electronics logic familiesDigital electronics logic families
Digital electronics logic families
 

Similar to 12.Representation of signed binary numbers. Binary codes - BCD code, Gray code, Excess-3 code..pptx

Comparators_and_Code_Convertersv.pptx.ppt
Comparators_and_Code_Convertersv.pptx.pptComparators_and_Code_Convertersv.pptx.ppt
Comparators_and_Code_Convertersv.pptx.pptHardikGupta400524
 
digital%20electronics.pptx
digital%20electronics.pptxdigital%20electronics.pptx
digital%20electronics.pptxansariparveen06
 
Lecture5 Chapter1- Binary Codes.pdf
Lecture5 Chapter1- Binary Codes.pdfLecture5 Chapter1- Binary Codes.pdf
Lecture5 Chapter1- Binary Codes.pdfUmerKhan147799
 
Conclusion in this titty tittle 106_1.ppt
Conclusion in this titty tittle 106_1.pptConclusion in this titty tittle 106_1.ppt
Conclusion in this titty tittle 106_1.pptKelvinSerimwe
 
DIGITAL ELECTRONICS
DIGITAL ELECTRONICSDIGITAL ELECTRONICS
DIGITAL ELECTRONICSSYEDJAMAESHA
 
Ece 301 lecture 2 - number systems and codes
Ece 301   lecture 2 - number systems and codesEce 301   lecture 2 - number systems and codes
Ece 301 lecture 2 - number systems and codesXiaolong Fang
 
digital logic circuits, digital component floting and fixed point
 digital logic circuits, digital component floting and fixed point digital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed pointRai University
 
21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptx21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptxGobinathAECEJRF1101
 
data representation
 data representation data representation
data representationHaroon_007
 
Finite word length effects
Finite word length effectsFinite word length effects
Finite word length effectsPeriyanayagiS
 
Computers numbering systems
Computers   numbering systemsComputers   numbering systems
Computers numbering systemssld1950
 
Unit-1 (DLD) Lecture 2.pptx
Unit-1 (DLD) Lecture 2.pptxUnit-1 (DLD) Lecture 2.pptx
Unit-1 (DLD) Lecture 2.pptxBunnyYadav7
 

Similar to 12.Representation of signed binary numbers. Binary codes - BCD code, Gray code, Excess-3 code..pptx (20)

Comparators_and_Code_Convertersv.pptx.ppt
Comparators_and_Code_Convertersv.pptx.pptComparators_and_Code_Convertersv.pptx.ppt
Comparators_and_Code_Convertersv.pptx.ppt
 
Code conversion r006
Code conversion r006Code conversion r006
Code conversion r006
 
Number system
Number systemNumber system
Number system
 
digital%20electronics.pptx
digital%20electronics.pptxdigital%20electronics.pptx
digital%20electronics.pptx
 
Codes r005
Codes  r005Codes  r005
Codes r005
 
DLD-Introduction.pptx
DLD-Introduction.pptxDLD-Introduction.pptx
DLD-Introduction.pptx
 
Alu1
Alu1Alu1
Alu1
 
Unit-1.pptx
Unit-1.pptxUnit-1.pptx
Unit-1.pptx
 
Lecture5 Chapter1- Binary Codes.pdf
Lecture5 Chapter1- Binary Codes.pdfLecture5 Chapter1- Binary Codes.pdf
Lecture5 Chapter1- Binary Codes.pdf
 
Conclusion in this titty tittle 106_1.ppt
Conclusion in this titty tittle 106_1.pptConclusion in this titty tittle 106_1.ppt
Conclusion in this titty tittle 106_1.ppt
 
DIGITAL ELECTRONICS
DIGITAL ELECTRONICSDIGITAL ELECTRONICS
DIGITAL ELECTRONICS
 
Ece 301 lecture 2 - number systems and codes
Ece 301   lecture 2 - number systems and codesEce 301   lecture 2 - number systems and codes
Ece 301 lecture 2 - number systems and codes
 
digital logic circuits, digital component floting and fixed point
 digital logic circuits, digital component floting and fixed point digital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed point
 
21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptx21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptx
 
data representation
 data representation data representation
data representation
 
digitalelectronics.ppt
digitalelectronics.pptdigitalelectronics.ppt
digitalelectronics.ppt
 
DLD_Lecture_notes2.ppt
DLD_Lecture_notes2.pptDLD_Lecture_notes2.ppt
DLD_Lecture_notes2.ppt
 
Finite word length effects
Finite word length effectsFinite word length effects
Finite word length effects
 
Computers numbering systems
Computers   numbering systemsComputers   numbering systems
Computers numbering systems
 
Unit-1 (DLD) Lecture 2.pptx
Unit-1 (DLD) Lecture 2.pptxUnit-1 (DLD) Lecture 2.pptx
Unit-1 (DLD) Lecture 2.pptx
 

Recently uploaded

HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 

Recently uploaded (20)

HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 

12.Representation of signed binary numbers. Binary codes - BCD code, Gray code, Excess-3 code..pptx

  • 1. TOPIC: Representation of binary numbers and Binary Codes Department of Electronics and Communication Engineering Chitkara University, Punjab, India Basic Electronics (22EC001) 1
  • 2. Representation of binary numbers Basic Electronics (22EC001) 2
  • 3. Unsigned Numbers • don’t have any sign • contain only magnitude of the number. Example-1: Represent decimal number 92 in unsigned binary number. (92)10 = (1011100)2 Basic Electronics (22EC001) 3
  • 4. Unsigned Numbers Example-2: Find range of 6 bit unsigned binary numbers. Also, find minimum and maximum value in this range. Sol: Since, range of unsigned binary number is from 0 to (2n-1). Therefore, range of 6 bit unsigned binary number is from 0 to (26-1) which is equal from minimum value 0 (i.e., 000000) to maximum value 63 (i.e., 111111). Basic Electronics (22EC001) 4
  • 5. Signed Numbers • Unsigned representation can be used for positive integers • How about negative integers? – Everything must be represented in binary numbers – Computers cannot use – or + signs Signed numbers: • contain sign flag • contains both sign bit and magnitude of a number • this representation distinguish positive and negative numbers • For negative numbers the sign bit is always 1, and for positive numbers it is 0 in these three systems Basic Electronics (22EC001) 5
  • 6. Representation of signed numbers There are two ways of representing negative binary numbers: 1. Sign Magnitude form 2. Complement Method - 1’s Complement form - 2’s Complement form • Advantage of using complement method for subtraction is reduction in hardware. • Instead of having separate circuits for addition and subtraction, only addition circuits are needed. Basic Electronics (22EC001) 6
  • 7. Sign-Magnitude form • For n bit binary number, 1 bit is reserved for sign symbol • The leftmost bit is the sign bit (0 is + and 1 is - ) and the remaining bits hold the absolute magnitude of the number • For 8 bits, we can represent the signed integers –127 to +127 • How about for N bits? -(2n-1-1)to +(2n-1 -1) • Examples • -47 = 1 0 1 0 1 1 1 1 • 47 = 0 0 1 0 1 1 1 1 Basic Electronics (22EC001) 7
  • 8. 1’s Complement form • Replace each 1 by 0 and each 0 by 1 • Example (-6) – First represent 6 in binary format (00000110) – Then replace (11111001) Basic Electronics (22EC001) 8
  • 9. 2’s Complement form • Find one’s complement • Add 1 • Example (-6) – First represent 6 in binary format (00000110) – One’s complement (11111001) – Two’s complement (11111010) Basic Electronics (22EC001) 9 Handy Trick: Leave all of the least significant 0’s and first 1 unchanged, and then “flip” the bits for all other digits. Eg: 01010100100 -> 10101011100
  • 10. 1’s and 2’s complements • 1’s complement of 10111001 – 11111111 – 10111001 = 01000110 – Simply replace 1’s and 0’s • 1’s complement of 10100010 – 01011101 • 2’s complement of 10111001 – 01000110 + 1 = 01000111 – Add 1 to 1’s complement • 2’s complement of 10100010 – 01011101 + 1 = 01011110 Basic Electronics (22EC001) 10
  • 11. NOTE • “Humans” normally use sign-magnitude representation for signed numbers – Eg: Positive numbers: +N or N – Negative numbers: -N • “Computers” generally use two’s-complement representation for signed numbers – First bit still indicates positive or negative. – If the number is negative, take 2’s complement to determine its magnitude Basic Electronics (22EC001) 11
  • 12. BINARY CODES Classification of Binary Codes: • BCD code • Excess three code • Gray code Basic Electronics (22EC001) 12
  • 13. Human Perception • We naturally live in a base 10 environment • Computer exist in a base 2 environment • So give the computer/digital system the task of doing the conversions for us. 13 Basic Electronics (22EC001)
  • 14. Binary Codes 14  A binary code represents text, computer processor instructions, or any other data using a two-symbol system. The two-symbol system used is often "0" and "1" from the binary number system.  The binary code assigns a pattern of binary digits, also known as bits, to each character, instruction, etc. Basic Electronics (22EC001)
  • 15. Classification of Binary Codes Basic Electronics (22EC001) 15
  • 16. Defination of BCD..Binary Coded Decimal •Binary coded decimal (BCD) is a system of writing numbers that assigns a four-digit binary code to each digit 0 through 9 in a decimal (base-10) numeral. • The four-bit BCD code for any particular single base-10 digit is its representation in binary notation, as follows: 0 = 0000 1 = 0001 2 = 0010 3 = 0011 4 = 0100 5 = 0101 6 = 0110 Basic Electronics (22EC001) 16
  • 17.  7 = 0111  8 = 1000  9 = 1001 Numbers larger than 9, having two or more digits in the decimal system, are expressed digit by digit. For example, the BCD rendition of the base-10 number 1895 is 1 8 9 5 0001 1000 1001 0101 Basic Electronics (22EC001) 17
  • 18. Why BCD is Used... • It is easy to encode and decode decimals into BCD and vice versa. • It is also simple to implement a hardware algorithm for the BCD converter. • It is very useful in digital systems whenever decimal information is given eitheras inputs or displayed as outputs. • Digital voltmeters, frequency converters and digital clocks all use BCD as they display output information in decimal Basic Electronics (22EC001) 18
  • 19. 8421 BCD Code • Valid BCD code are : 0000 to 1001 • Invalid BCD code are :1010 to 1111 Example: Decimal number 4926 4 9 2 6 BCD coded number 0100 1001 0010 0110 Basic Electronics (22EC001) 19
  • 20. Contd. Convert the BCD coded number 1000 0111 0001 into decimal. BCD Coded Number 1000 0111 0001 Decimal Number 8 7 1 Basic Electronics (22EC001) 20
  • 21. Convert the decimal number 350 to its BCD equivalent. Decimal Number 3 5 0 BCD Coded Number 0011 0101 0000 Contd. Basic Electronics (22EC001) 21
  • 22. Excess 3 Code • Add 3 to each digit of decimal and convert it to 4-bit binary form. • Valid excess-3 code : 0011 to 1100 • Invalid excess-3 code : [0000 to 0010] and [1101 to 1111] Decimal Binary +3 Excess-3 0 0000 0011 0011 1 0001 0011 0100 2 0010 0011 0101 3 0011 0011 0110 4 0100 0011 0111 5 0101 0011 1000 6 0110 0011 1001 7 0111 0011 1010 8 1000 0011 1011 9 1001 0011 1100 Decimal 3 5 9 Sample Problem: Excess-3 0110 1000 1100 Basic Electronics (22EC001) 22
  • 23. Gray Code • The Gray code’s most important characteristic is that only one digit changes as you increment or decrement the count. (unit distance code) • The Gray code is NOT a BCD code. Decimal Gray code 0 00000 1 00001 2 00011 3 00010 4 00110 5 00111 6 00101 7 00100 8 01100 9 01101 10 01111 11 01110 12 01010 13 01011 14 01001 15 01000 16 11000 Basic Electronics (22EC001) 23
  • 24. Binary to Gray Code Conversion • The MSB in the Gray code is the same as corresponding MSB in the binary number. • Going from left to right, add each adjacent pair of binary code bits to get the next Gray code bit. Discard carries. • Example 1: • Example 2: Basic Electronics (22EC001) 24
  • 25. Activity 1: Convert the following binary codes to gray codes: 1. 10010111 2. 10001001 3. 01101010 Convert the following to Gray codes: 4. (527)8 - 1111 11100 5. (3A7)16 - 0 010 0111 0100 Basic Electronics (22EC001) 25
  • 26. Gray to Binary Conversion • The MSB in the Binary code is the same as corresponding MSB in the Gray number. • Going from bottom to top, add each pair of gray code bits to get the next binary code bit. Discard carries. • Example 1: • Example 2: Basic Electronics (22EC001) 26
  • 27. Activity 2: Convert the following gray codes to binary codes: 1. 11001100 10001000 1. 00110011 2. 00100010 3. 11111000 4. 10101111 11111000 10101111 11111000 Basic Electronics (22EC001) 27