SlideShare a Scribd company logo
Dr. Anita Goel
Assoc. Prof. (Computer Sci.)
Dyal Singh College, University of Delhi
 Introduction
 Binary Arithmetic
 Signed and Unsigned Numbers
 Binary Data Representation
 Binary Coding Schemes
2
 Uses digits 0-9
 Digits combined to form numbers like 104,
4561
 Decimal arithmetic operations
 Addition, subtraction, multiplication, division
 For e.g., a chocolate costs Rs. 5/-. Total
cost of 2 chocolates will be Rs. 10/- i.e.
(5*2) or (5+5)
3
 Used in computer systems
 Uses digits 0’s and 1’s only
 Digits combined to form numbers like
1001, 11000110
 A digit 0 or 1 is called a bit (binary digit)
 1001 is a 4-bit number.
 11000110 is an 8-bit number
4
 All data is represented internally in a
computer by a combination of bits.
 Each symbol is represented by a
combination of bits.
5
 Arithmetic operations performed on binary
numbers is called binary arithmetic.
 addition, subtraction, multiplication, division.
 Computer systems actually perform only
Binary Addition and Binary Subtraction.
 Binary Multiplication and Division is
performed using some simple operations
6
 Involves addition of two or more binary
numbers.
 Uses Binary addition rules
7
8
Input 1 Input 2 Sum Carry
0 0 0 No carry
0 1 1 No carry
1 0 1 No carry
1 1 0 1
9
Input 1 Input 2 Input 3 Sum Carry
1 1 1 1 1
1. Start by adding bits in unit column (rightmost
column)
2. Result of adding bits of a column is a sum with
or without a carry.
3. Write sum in result of that column.
4. If carry is present, carry is carried-over to
addition of the adjacent left column.
5. Then repeat the above steps, for each of the
columns, i.e., tens column, hundreds column
and so on.
10
Example 1. Add 10 and 01. Verify answer with the
help of decimal addition.
11
Binary Addition
1 0
+ 0 1
11
Decimal Addition
2
1+
3
112 = 310
Example 2. Add 01 and 11. Verify answer with the
help of decimal addition.
12
Binary Addition
0 1
+ 1 1
00
Decimal Addition
1
3+
4
1
1
1002 = 410
Example 3. Add 11 and 11. Verify answer with the
help of decimal addition.
13
Binary Addition
1 1
+ 1 1
01
Decimal Addition
3
3+
6
1
1
1102 = 610
Example 4. Add 1101 and 1111. Verify answer with
the help of decimal addition.
14
Binary Addition
1 1 0 1
+ 1 1 1 1
01
Decimal Addition
1 3
1 5+
2 8
1
1
11
01
111002 = 2810
Example 5. Add 10111, 11100 and 11. Verify answer
with the help of decimal addition.
15
Binary Addition
1 0 1 1 1
1 1 1 0 0
+ 1 1
01
Decimal Addition
2 3
2 8
3+
5 4
1
0
11
11
1
1
1101102 = 5410
 Uses Binary subtraction rules
16
Input 1 Input 2 Difference Borrow
0 0 0 No borrow
0 1 1 1
1 0 1 No borrow
1 1 0 No borrow
Binary Subtraction Rules
1. Start by subtracting bit in lower row from bit in
upper row, in unit column.
2. If bit in upper row is less than the bit in lower row,
borrow 1 from upper row of adjacent left column.
3. Result of subtracting two bits is the difference.
4. Write difference in result of that column.
5. Then repeat the above steps, for each of the
columns, i.e., tens column, hundreds column and
so on.
17
Example 1. Subtract 01 from 11. Verify answer
with the help of decimal subtraction.
18
Binary Subtraction
1 1
- 0 1
01
Decimal Subtraction
3
1-
2
102 = 210
Example 2. Subtract 01 from 10. Verify answer
with the help of decimal subtraction.
19
Binary Subtraction
1 0
- 0 1
10
Decimal Subtraction
2
1-
1
10
012 = 110
0
Example 3. Subtract 0111 from 1110. Verify answer
with the help of decimal subtraction.
20
Binary Subtraction
1 1 1 0
- 0 1 1 1
10
Decimal Subtraction
1 4
7-
7
10
10
11
10
01112 = 710
000
Example 4 Subtract 10010 from 10101. Verify
answer with the help of decimal
subtraction.
21
Binary Subtraction
1 0 1 0 1
- 1 0 0 1 0
10
Decimal Subtraction
2 1
1 8-
3
10
100
000112 = 310
0
Example 5. Subtract 101111 from 110001. Verify
answer with the help of decimal
subtraction.
22
Binary Subtraction
1 1 0 0 0 1
- 1 0 1 1 1 1
10
Decimal Subtraction
4 9
4 7-
2
101010
00 0 0
11
0000102 = 210
0
 A binary number may be positive or
negative.
 Generally, symbols “+” and “-” represent
positive and negative numbers,
respectively.
 In computer, sign of a binary number has
to be represented using 0 and 1.
23
 n-bit signed binary number consists of two parts
 Sign bit, and Magnitude.
 Left most bit is called Most Significant Bit (MSB).
 MSB is the sign bit.
 Remaining n-1 bits denote magnitude of number.
24
MSB
Sign bit Magnitude
1 bit n-1 bits
 Sign bit is 0 for a positive number and 1 for
a negative number.
 0 1100011 is a positive number. Sign bit is 0,
and,
 1 1001011 is a negative number. Sign bit is 1.
25
0 1100011
MSB
1 1001011
MSB
Positive Number Negative Number
 Data range for 8-bit signed number is:
 -128 to +127 (-27 to +27-1).
 Leftmost bit is sign bit.
 In n-bit unsigned binary number,
magnitude of number n is stored in n bits.
 Data range for 8-bit unsigned number is:
 0 to 255 (28= 256).
26
 Used in computer for simplification of
subtraction operation.
 Two types of complements
 1’s complement, and
 2’ s complement.
27
 Change bits 1 to 0 and bits 0 to 1.
 Some examples
Binary
Numbers
1’s
Complement
28
1 1 0
0 0 1
1 0 1 1
0 1 0 0 0 0 1 0 0 0 0
1 1 0 1 1 1 1
 Add 1 to the 1’s complement of the binary number.
 Some Examples:
Binary
Numbers
1’s
Complement
2’s
Complement
29
0 1 0 0 1 0 1 0 0 1 0 0 0 1
1 1 0 1 0 1 1 1 1 0 1 1 1 1
0 0 1 0 1 0 0 0 0 1 0 0 0 0
 Binary number can also have a binary
point, in addition to sign.
 Binary point used for representing
fractions, integers and integer-fraction
numbers.
 Registers are high-speed storage areas in
CPU of computer. All data is brought into a
register before it gets processed.
30
 Two ways of representing position of
binary point in a register
 Fixed Point Number Representation, and
 Floating Point Number Representation.
31
 Assumes binary point is fixed at one position.
 Represents +ve integer binary signed number as-
 Sign bit is 0. Magnitude is a positive binary number.
 Represents -ve integer binary signed number as-
 Sign bit is 1
 Magnitude is represented in any one of three ways-
 Signed Magnitude representation
 Signed 1’s complement representation
 Signed 2’s complement representation
32
 Signed Magnitude representation
 Magnitude is positive binary number itself.
 Signed 1’s complement representation
 Magnitude is 1’s complement of positive binary
number.
 Signed 2’s complement representation
 Magnitude is 2’s complement of positive binary
number.
33
+18
0 0 0 1 0 0 1 0
Sign bit is 0 Binary equivalent of +18
-18
Signed
magnitude
representation
1 0 0 1 0 0 1 0
Sign bit is 1 Binary equivalent of +18
Signed 1’s
complement
representation
1 1 1 0 1 1 0 1
Sign bit is 1 1’s complement of +18
Signed 2’s
complement
representation
1 1 1 0 1 1 1 0
Sign bit is 1 2’s complement of +18
Fixed Point Representation of
Signed Number 18
34
 Signed magnitude and signed 1’s
complement representation are rarely used
in computer arithmetic.
 Signed 2’s complement representation is
used to represent negative numbers.
35
 Represent positive number in binary form.
 For e.g., +5 is 0000 0101, +10 is 0000 1010
 Represent negative number in 2’s
complement form.
 For e.g., -5 is 111 1 1011, -10 is 1111 0110
 Add bits of the two signed binary numbers.
 Ignore any carry out from sign bit position.
36
 Negative output is automatically in 2’s
complement form.
 Get decimal equivalent of negative output
number
 Find its 2’s complement, and
 Attach a negative sign to the obtained result.
37
Example 1. Add binary +5 and +10. Verify answer
with the help of decimal addition.
38
Binary Addition
0 0 0 0 0 1 0 1
+ 0 0 0 0 1 0 1 0
0 100 0
Decimal Addition
5
1 0+
1 5
+
+1 11
0000 11112 = +1510
Example 2. Add binary -5 and +10. Verify answer
with the help of decimal addition.
39
Binary Addition
1 1 1 1 1 0 1 1
+ 0 0 0 0 1 0 1 0
0 000 0
Decimal Addition
5
1 0+
5
-
+0 11
111111
0000 01012 = +510
Example 3. Add binary +5 and -10. Verify answer
with the help of decimal addition.
40
Binary Addition
0 0 0 0 0 1 0 1
+ 1 1 1 1 0 1 1 0
1 111 1
Decimal Addition
5
1 0-
5
+
-1 10
1
1111 10112 = -510
Example 4. Add binary -5 and -10. Verify answer
with the help of decimal addition.
41
Binary Addition
1 1 1 1 1 0 1 1
+ 1 1 1 1 0 1 1 0
1 011 1
Decimal Addition
5
1 0-
1 5
-
-0 10
111 1 11 1
1111 00012 = -1510
 Changed to addition of two signed numbers.
 Sign of second number is changed before
performing the addition operation.
42
(+A) – (+B) = (+A) + (-B)
(+A) – (-B) = (+A) + (+B)
(-A) – (-B) = (-A) + (+B)
(-A) – (+B) = (-A) + (-B)
43
 Uses two registers
 1st register stores number without binary point.
 2nd register stores a number that indicates position
of binary point in first register.
 Consists of two parts:
 Mantissa, and Exponent.
 Mantissa is a signed fixed point number.
 Exponent shows position of binary point in
mantissa.
44
45
Represent binary number +11001.11 with
8-bit mantissa and 6-bit exponent
Floating point number is: Mantissa x 2exponent
+ (.1100111) x 2+5.
Mantissa Exponent
number is positive binary equivalent of +5
0 11 0 0 111 0 0 0 1 0 1
11 0 0 1 . 11 . 11 0 0 111 x 2 5
 Data - alphabetic, numeric, alphanumeric,
sound, video.
 Data represented as combination of bits in
computer.
 Bits are grouped in a fixed size.
 Code is made by combining bits of definite
size.
46
 Represents symbols in a standard code.
 Combination of bits represents a unique
symbol.
 Standard code enables programmers to
use same combination of bits to represent
a symbol in data.
47
 Commonly used binary coding schemes:
 ASCII,
 EBCDIC, and
 Unicode
48
 EBCDIC stands for Extended Binary Coded
Decimal Interchange Code
 8-bit code. 4 bits for zone; 4 bits for digit.
 Allows 28 = 256 combinations.
 Represents 256 unique symbols.
 Used mainly in mainframe computers.
49
 ASCII stands for American Standard Code
for Information Interchange
 Two types of ASCII codes
 ASCII-7 and
 ASCII-8.
50
 Standard ASCII code.
 7-bit code. 3 bits for zone; 4 bits for digits.
 Allows 27 = 128 combinations.
 Represents 128 unique symbols.
 ASCII-7 modified by IBM to ASCII-8.
51
 Extended version of ASCII-7.
 8-bit code. 4 bits for zone; 4 bits for digit.
 Allows 28 = 256 combinations.
 Represents 256 unique symbols.
 Widely used to represent data in computer.
52
 ASCII-8 code represents 256 symbols.
 0-31 for control characters.
 Non-printable. Carriage Return (CR), Bell
(BEL).
 48-57 for numeric 0-9.
 65-90 for uppercase letters A-Z.
 97-122 for lowercase letters a-z.
 128-255 are extended ASCII codes.
53
 Universal character encoding standard
 Represents text, symbols, characters in multi-
lingual environments.
 Uniquely represent a symbol in languages like
Chinese, Japanese etc.
 Represents mathematical and scientific
symbols.
 32 bit code.
 Allows 232 = approx. 4 billion combinations.
54
 Compatible with ASCII-8 codes.
 Unicode’s first 256 codes identical to ASCII-
8 codes.
 Implemented by character encodings.
 UTF-8 : A character encoding
 Most commonly used encoding scheme.
 Uses 8-32 bits per code.
55
Unicode character encoding
in MS-Word 2007
56
Binaty Arithmetic and Binary coding schemes

More Related Content

What's hot (20)

PPT
Logic Micro Operation
mahesh kumar prajapat
 
PPTX
Basic Computer Organization and Design
Aksum Institute of Technology(AIT, @Letsgo)
 
PPT
Two’s complement
mayannpolisticoLNU
 
PPTX
Linear search-and-binary-search
International Islamic University
 
PPTX
Logical and shift micro operations
Sanjeev Patel
 
PPTX
Floating point arithmetic operations (1)
cs19club
 
PPTX
Floating point representation
missstevenson01
 
PPTX
1's and 2's complement
Shiraz Azeem
 
PPTX
instruction cycle ppt
sheetal singh
 
PPTX
Topological Sorting
ShahDhruv21
 
PPTX
Logical micro-operations
VATSAL TRIVEDI
 
PDF
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
Arti Parab Academics
 
PPS
Computer instructions
Anuj Modi
 
PPTX
Number system in Digital Electronics
Janki Shah
 
PPTX
Multiplication algorithm, hardware and flowchart
Tanjarul Islam Mishu
 
PPTX
Computer architecture control unit
Mazin Alwaaly
 
PPTX
Array in c++
Mahesha Mano
 
PPTX
Data Representation
Dilum Bandara
 
Logic Micro Operation
mahesh kumar prajapat
 
Basic Computer Organization and Design
Aksum Institute of Technology(AIT, @Letsgo)
 
Two’s complement
mayannpolisticoLNU
 
Linear search-and-binary-search
International Islamic University
 
Logical and shift micro operations
Sanjeev Patel
 
Floating point arithmetic operations (1)
cs19club
 
Floating point representation
missstevenson01
 
1's and 2's complement
Shiraz Azeem
 
instruction cycle ppt
sheetal singh
 
Topological Sorting
ShahDhruv21
 
Logical micro-operations
VATSAL TRIVEDI
 
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
Arti Parab Academics
 
Computer instructions
Anuj Modi
 
Number system in Digital Electronics
Janki Shah
 
Multiplication algorithm, hardware and flowchart
Tanjarul Islam Mishu
 
Computer architecture control unit
Mazin Alwaaly
 
Array in c++
Mahesha Mano
 
Data Representation
Dilum Bandara
 

Similar to Binaty Arithmetic and Binary coding schemes (20)

PPTX
Computer Architecture
Ravi Kumar
 
PPTX
Computer Architecture
Ravi Kumar
 
PPT
Number system and codes
Abhiraj Bohra
 
PDF
Finite word length effects
PeriyanayagiS
 
PPT
Counit2
Himanshu Dua
 
PDF
Computer Architecture: ARITHMETIC FOR COMPUTERS
Gunasundari Selvaraj
 
PPTX
module 1_class_numbers.pptx
ssuser2efca7
 
PPTX
CA Unit ii
AmirthavalliR
 
PPTX
ARITHMETIC FOR COMPUTERS
Amirthavalli Senthil
 
PPT
Digital fundamendals r001a
arunachalamr16
 
PPT
Comp Arithmetic Basic.ppt
skatiarrahaman
 
PPT
ch3a-binary-numbers.ppt
RabiaAsif31
 
PPTX
DEC Unit 1 Full-1.pptx Boolean Algebra and Logic gates
naveenkaueee
 
PPT
Chapter 02 Data Types
Nathan Yeung
 
PPT
ch3a-binary-numbers.ppt
MUNAZARAZZAQELEA
 
PPT
ch3a-binary-numbers.ppt ch3a-binary-numbers.ppt ch3a-binary-numbers.ppt
anilmallah76
 
PPT
ch3a-binary-numbers.ppt
RAJKUMARP63
 
PPT
ch3a-binary-numbers.ppt
ssuser52a19e
 
PPT
Review on Number Systems: Decimal, Binary, and Hexadecimal
UtkirjonUbaydullaev1
 
PPT
mmmmmmmmmmmmmmmmmmmmmmbinary-numbers.ppt
AdityaGupta221734
 
Computer Architecture
Ravi Kumar
 
Computer Architecture
Ravi Kumar
 
Number system and codes
Abhiraj Bohra
 
Finite word length effects
PeriyanayagiS
 
Counit2
Himanshu Dua
 
Computer Architecture: ARITHMETIC FOR COMPUTERS
Gunasundari Selvaraj
 
module 1_class_numbers.pptx
ssuser2efca7
 
CA Unit ii
AmirthavalliR
 
ARITHMETIC FOR COMPUTERS
Amirthavalli Senthil
 
Digital fundamendals r001a
arunachalamr16
 
Comp Arithmetic Basic.ppt
skatiarrahaman
 
ch3a-binary-numbers.ppt
RabiaAsif31
 
DEC Unit 1 Full-1.pptx Boolean Algebra and Logic gates
naveenkaueee
 
Chapter 02 Data Types
Nathan Yeung
 
ch3a-binary-numbers.ppt
MUNAZARAZZAQELEA
 
ch3a-binary-numbers.ppt ch3a-binary-numbers.ppt ch3a-binary-numbers.ppt
anilmallah76
 
ch3a-binary-numbers.ppt
RAJKUMARP63
 
ch3a-binary-numbers.ppt
ssuser52a19e
 
Review on Number Systems: Decimal, Binary, and Hexadecimal
UtkirjonUbaydullaev1
 
mmmmmmmmmmmmmmmmmmmmmmbinary-numbers.ppt
AdityaGupta221734
 
Ad

More from Dr. Anita Goel (6)

PDF
Big data and cloud computing 9 sep-2017
Dr. Anita Goel
 
PDF
Scientific writing anita goel du
Dr. Anita Goel
 
PDF
Cloud computing infrastructure
Dr. Anita Goel
 
PDF
MOOC and OER for Student Participation and Collaborative Learning
Dr. Anita Goel
 
PDF
Good governance through e-Governance
Dr. Anita Goel
 
PDF
Open office impress
Dr. Anita Goel
 
Big data and cloud computing 9 sep-2017
Dr. Anita Goel
 
Scientific writing anita goel du
Dr. Anita Goel
 
Cloud computing infrastructure
Dr. Anita Goel
 
MOOC and OER for Student Participation and Collaborative Learning
Dr. Anita Goel
 
Good governance through e-Governance
Dr. Anita Goel
 
Open office impress
Dr. Anita Goel
 
Ad

Recently uploaded (20)

PPTX
JSON, XML and Data Science introduction.pptx
Ramakrishna Reddy Bijjam
 
PPT
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
PDF
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
PDF
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
PPTX
Martyrs of Ireland - who kept the faith of St. Patrick.pptx
Martin M Flynn
 
PDF
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
PPTX
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
 
DOCX
ANNOTATION on objective 10 on pmes 2022-2025
joviejanesegundo1
 
PPTX
How Physics Enhances Our Quality of Life.pptx
AngeliqueTolentinoDe
 
PPTX
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
 
PDF
Nanotechnology and Functional Foods Effective Delivery of Bioactive Ingredien...
rmswlwcxai8321
 
PPTX
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
PPTX
ENGLISH -PPT- Week1 Quarter1 -day-1.pptx
garcialhavz
 
PDF
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
PPTX
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
 
PPTX
Photo chemistry Power Point Presentation
mprpgcwa2024
 
PDF
Learning Styles Inventory for Senior High School Students
Thelma Villaflores
 
DOCX
DLL english grade five goof for one week
FlordelynGonzales1
 
PPTX
How to use _name_search() method in Odoo 18
Celine George
 
PPTX
ESP 10 Edukasyon sa Pagpapakatao PowerPoint Lessons Quarter 1.pptx
Sir J.
 
JSON, XML and Data Science introduction.pptx
Ramakrishna Reddy Bijjam
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
Martyrs of Ireland - who kept the faith of St. Patrick.pptx
Martin M Flynn
 
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
 
ANNOTATION on objective 10 on pmes 2022-2025
joviejanesegundo1
 
How Physics Enhances Our Quality of Life.pptx
AngeliqueTolentinoDe
 
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
 
Nanotechnology and Functional Foods Effective Delivery of Bioactive Ingredien...
rmswlwcxai8321
 
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
ENGLISH -PPT- Week1 Quarter1 -day-1.pptx
garcialhavz
 
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
 
Photo chemistry Power Point Presentation
mprpgcwa2024
 
Learning Styles Inventory for Senior High School Students
Thelma Villaflores
 
DLL english grade five goof for one week
FlordelynGonzales1
 
How to use _name_search() method in Odoo 18
Celine George
 
ESP 10 Edukasyon sa Pagpapakatao PowerPoint Lessons Quarter 1.pptx
Sir J.
 

Binaty Arithmetic and Binary coding schemes

  • 1. Dr. Anita Goel Assoc. Prof. (Computer Sci.) Dyal Singh College, University of Delhi
  • 2.  Introduction  Binary Arithmetic  Signed and Unsigned Numbers  Binary Data Representation  Binary Coding Schemes 2
  • 3.  Uses digits 0-9  Digits combined to form numbers like 104, 4561  Decimal arithmetic operations  Addition, subtraction, multiplication, division  For e.g., a chocolate costs Rs. 5/-. Total cost of 2 chocolates will be Rs. 10/- i.e. (5*2) or (5+5) 3
  • 4.  Used in computer systems  Uses digits 0’s and 1’s only  Digits combined to form numbers like 1001, 11000110  A digit 0 or 1 is called a bit (binary digit)  1001 is a 4-bit number.  11000110 is an 8-bit number 4
  • 5.  All data is represented internally in a computer by a combination of bits.  Each symbol is represented by a combination of bits. 5
  • 6.  Arithmetic operations performed on binary numbers is called binary arithmetic.  addition, subtraction, multiplication, division.  Computer systems actually perform only Binary Addition and Binary Subtraction.  Binary Multiplication and Division is performed using some simple operations 6
  • 7.  Involves addition of two or more binary numbers.  Uses Binary addition rules 7
  • 8. 8 Input 1 Input 2 Sum Carry 0 0 0 No carry 0 1 1 No carry 1 0 1 No carry 1 1 0 1
  • 9. 9 Input 1 Input 2 Input 3 Sum Carry 1 1 1 1 1
  • 10. 1. Start by adding bits in unit column (rightmost column) 2. Result of adding bits of a column is a sum with or without a carry. 3. Write sum in result of that column. 4. If carry is present, carry is carried-over to addition of the adjacent left column. 5. Then repeat the above steps, for each of the columns, i.e., tens column, hundreds column and so on. 10
  • 11. Example 1. Add 10 and 01. Verify answer with the help of decimal addition. 11 Binary Addition 1 0 + 0 1 11 Decimal Addition 2 1+ 3 112 = 310
  • 12. Example 2. Add 01 and 11. Verify answer with the help of decimal addition. 12 Binary Addition 0 1 + 1 1 00 Decimal Addition 1 3+ 4 1 1 1002 = 410
  • 13. Example 3. Add 11 and 11. Verify answer with the help of decimal addition. 13 Binary Addition 1 1 + 1 1 01 Decimal Addition 3 3+ 6 1 1 1102 = 610
  • 14. Example 4. Add 1101 and 1111. Verify answer with the help of decimal addition. 14 Binary Addition 1 1 0 1 + 1 1 1 1 01 Decimal Addition 1 3 1 5+ 2 8 1 1 11 01 111002 = 2810
  • 15. Example 5. Add 10111, 11100 and 11. Verify answer with the help of decimal addition. 15 Binary Addition 1 0 1 1 1 1 1 1 0 0 + 1 1 01 Decimal Addition 2 3 2 8 3+ 5 4 1 0 11 11 1 1 1101102 = 5410
  • 16.  Uses Binary subtraction rules 16 Input 1 Input 2 Difference Borrow 0 0 0 No borrow 0 1 1 1 1 0 1 No borrow 1 1 0 No borrow Binary Subtraction Rules
  • 17. 1. Start by subtracting bit in lower row from bit in upper row, in unit column. 2. If bit in upper row is less than the bit in lower row, borrow 1 from upper row of adjacent left column. 3. Result of subtracting two bits is the difference. 4. Write difference in result of that column. 5. Then repeat the above steps, for each of the columns, i.e., tens column, hundreds column and so on. 17
  • 18. Example 1. Subtract 01 from 11. Verify answer with the help of decimal subtraction. 18 Binary Subtraction 1 1 - 0 1 01 Decimal Subtraction 3 1- 2 102 = 210
  • 19. Example 2. Subtract 01 from 10. Verify answer with the help of decimal subtraction. 19 Binary Subtraction 1 0 - 0 1 10 Decimal Subtraction 2 1- 1 10 012 = 110 0
  • 20. Example 3. Subtract 0111 from 1110. Verify answer with the help of decimal subtraction. 20 Binary Subtraction 1 1 1 0 - 0 1 1 1 10 Decimal Subtraction 1 4 7- 7 10 10 11 10 01112 = 710 000
  • 21. Example 4 Subtract 10010 from 10101. Verify answer with the help of decimal subtraction. 21 Binary Subtraction 1 0 1 0 1 - 1 0 0 1 0 10 Decimal Subtraction 2 1 1 8- 3 10 100 000112 = 310 0
  • 22. Example 5. Subtract 101111 from 110001. Verify answer with the help of decimal subtraction. 22 Binary Subtraction 1 1 0 0 0 1 - 1 0 1 1 1 1 10 Decimal Subtraction 4 9 4 7- 2 101010 00 0 0 11 0000102 = 210 0
  • 23.  A binary number may be positive or negative.  Generally, symbols “+” and “-” represent positive and negative numbers, respectively.  In computer, sign of a binary number has to be represented using 0 and 1. 23
  • 24.  n-bit signed binary number consists of two parts  Sign bit, and Magnitude.  Left most bit is called Most Significant Bit (MSB).  MSB is the sign bit.  Remaining n-1 bits denote magnitude of number. 24 MSB Sign bit Magnitude 1 bit n-1 bits
  • 25.  Sign bit is 0 for a positive number and 1 for a negative number.  0 1100011 is a positive number. Sign bit is 0, and,  1 1001011 is a negative number. Sign bit is 1. 25 0 1100011 MSB 1 1001011 MSB Positive Number Negative Number
  • 26.  Data range for 8-bit signed number is:  -128 to +127 (-27 to +27-1).  Leftmost bit is sign bit.  In n-bit unsigned binary number, magnitude of number n is stored in n bits.  Data range for 8-bit unsigned number is:  0 to 255 (28= 256). 26
  • 27.  Used in computer for simplification of subtraction operation.  Two types of complements  1’s complement, and  2’ s complement. 27
  • 28.  Change bits 1 to 0 and bits 0 to 1.  Some examples Binary Numbers 1’s Complement 28 1 1 0 0 0 1 1 0 1 1 0 1 0 0 0 0 1 0 0 0 0 1 1 0 1 1 1 1
  • 29.  Add 1 to the 1’s complement of the binary number.  Some Examples: Binary Numbers 1’s Complement 2’s Complement 29 0 1 0 0 1 0 1 0 0 1 0 0 0 1 1 1 0 1 0 1 1 1 1 0 1 1 1 1 0 0 1 0 1 0 0 0 0 1 0 0 0 0
  • 30.  Binary number can also have a binary point, in addition to sign.  Binary point used for representing fractions, integers and integer-fraction numbers.  Registers are high-speed storage areas in CPU of computer. All data is brought into a register before it gets processed. 30
  • 31.  Two ways of representing position of binary point in a register  Fixed Point Number Representation, and  Floating Point Number Representation. 31
  • 32.  Assumes binary point is fixed at one position.  Represents +ve integer binary signed number as-  Sign bit is 0. Magnitude is a positive binary number.  Represents -ve integer binary signed number as-  Sign bit is 1  Magnitude is represented in any one of three ways-  Signed Magnitude representation  Signed 1’s complement representation  Signed 2’s complement representation 32
  • 33.  Signed Magnitude representation  Magnitude is positive binary number itself.  Signed 1’s complement representation  Magnitude is 1’s complement of positive binary number.  Signed 2’s complement representation  Magnitude is 2’s complement of positive binary number. 33
  • 34. +18 0 0 0 1 0 0 1 0 Sign bit is 0 Binary equivalent of +18 -18 Signed magnitude representation 1 0 0 1 0 0 1 0 Sign bit is 1 Binary equivalent of +18 Signed 1’s complement representation 1 1 1 0 1 1 0 1 Sign bit is 1 1’s complement of +18 Signed 2’s complement representation 1 1 1 0 1 1 1 0 Sign bit is 1 2’s complement of +18 Fixed Point Representation of Signed Number 18 34
  • 35.  Signed magnitude and signed 1’s complement representation are rarely used in computer arithmetic.  Signed 2’s complement representation is used to represent negative numbers. 35
  • 36.  Represent positive number in binary form.  For e.g., +5 is 0000 0101, +10 is 0000 1010  Represent negative number in 2’s complement form.  For e.g., -5 is 111 1 1011, -10 is 1111 0110  Add bits of the two signed binary numbers.  Ignore any carry out from sign bit position. 36
  • 37.  Negative output is automatically in 2’s complement form.  Get decimal equivalent of negative output number  Find its 2’s complement, and  Attach a negative sign to the obtained result. 37
  • 38. Example 1. Add binary +5 and +10. Verify answer with the help of decimal addition. 38 Binary Addition 0 0 0 0 0 1 0 1 + 0 0 0 0 1 0 1 0 0 100 0 Decimal Addition 5 1 0+ 1 5 + +1 11 0000 11112 = +1510
  • 39. Example 2. Add binary -5 and +10. Verify answer with the help of decimal addition. 39 Binary Addition 1 1 1 1 1 0 1 1 + 0 0 0 0 1 0 1 0 0 000 0 Decimal Addition 5 1 0+ 5 - +0 11 111111 0000 01012 = +510
  • 40. Example 3. Add binary +5 and -10. Verify answer with the help of decimal addition. 40 Binary Addition 0 0 0 0 0 1 0 1 + 1 1 1 1 0 1 1 0 1 111 1 Decimal Addition 5 1 0- 5 + -1 10 1 1111 10112 = -510
  • 41. Example 4. Add binary -5 and -10. Verify answer with the help of decimal addition. 41 Binary Addition 1 1 1 1 1 0 1 1 + 1 1 1 1 0 1 1 0 1 011 1 Decimal Addition 5 1 0- 1 5 - -0 10 111 1 11 1 1111 00012 = -1510
  • 42.  Changed to addition of two signed numbers.  Sign of second number is changed before performing the addition operation. 42
  • 43. (+A) – (+B) = (+A) + (-B) (+A) – (-B) = (+A) + (+B) (-A) – (-B) = (-A) + (+B) (-A) – (+B) = (-A) + (-B) 43
  • 44.  Uses two registers  1st register stores number without binary point.  2nd register stores a number that indicates position of binary point in first register.  Consists of two parts:  Mantissa, and Exponent.  Mantissa is a signed fixed point number.  Exponent shows position of binary point in mantissa. 44
  • 45. 45 Represent binary number +11001.11 with 8-bit mantissa and 6-bit exponent Floating point number is: Mantissa x 2exponent + (.1100111) x 2+5. Mantissa Exponent number is positive binary equivalent of +5 0 11 0 0 111 0 0 0 1 0 1 11 0 0 1 . 11 . 11 0 0 111 x 2 5
  • 46.  Data - alphabetic, numeric, alphanumeric, sound, video.  Data represented as combination of bits in computer.  Bits are grouped in a fixed size.  Code is made by combining bits of definite size. 46
  • 47.  Represents symbols in a standard code.  Combination of bits represents a unique symbol.  Standard code enables programmers to use same combination of bits to represent a symbol in data. 47
  • 48.  Commonly used binary coding schemes:  ASCII,  EBCDIC, and  Unicode 48
  • 49.  EBCDIC stands for Extended Binary Coded Decimal Interchange Code  8-bit code. 4 bits for zone; 4 bits for digit.  Allows 28 = 256 combinations.  Represents 256 unique symbols.  Used mainly in mainframe computers. 49
  • 50.  ASCII stands for American Standard Code for Information Interchange  Two types of ASCII codes  ASCII-7 and  ASCII-8. 50
  • 51.  Standard ASCII code.  7-bit code. 3 bits for zone; 4 bits for digits.  Allows 27 = 128 combinations.  Represents 128 unique symbols.  ASCII-7 modified by IBM to ASCII-8. 51
  • 52.  Extended version of ASCII-7.  8-bit code. 4 bits for zone; 4 bits for digit.  Allows 28 = 256 combinations.  Represents 256 unique symbols.  Widely used to represent data in computer. 52
  • 53.  ASCII-8 code represents 256 symbols.  0-31 for control characters.  Non-printable. Carriage Return (CR), Bell (BEL).  48-57 for numeric 0-9.  65-90 for uppercase letters A-Z.  97-122 for lowercase letters a-z.  128-255 are extended ASCII codes. 53
  • 54.  Universal character encoding standard  Represents text, symbols, characters in multi- lingual environments.  Uniquely represent a symbol in languages like Chinese, Japanese etc.  Represents mathematical and scientific symbols.  32 bit code.  Allows 232 = approx. 4 billion combinations. 54
  • 55.  Compatible with ASCII-8 codes.  Unicode’s first 256 codes identical to ASCII- 8 codes.  Implemented by character encodings.  UTF-8 : A character encoding  Most commonly used encoding scheme.  Uses 8-32 bits per code. 55
  • 56. Unicode character encoding in MS-Word 2007 56