The document provides an in-depth overview of binary arithmetic, including operations such as addition, subtraction, and representation of signed and unsigned numbers in binary form. It explains binary coding schemes like ASCII, EBCDIC, and Unicode, detailing how data is represented in computers using bits. The text further discusses the significance of binary operations, formats for positive and negative numbers, and the use of floating-point representation.
Introduction
BinaryArithmetic
Signed and Unsigned Numbers
Binary Data Representation
Binary Coding Schemes
2
3.
Uses digits0-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 incomputer 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 datais represented internally in a
computer by a combination of bits.
Each symbol is represented by a
combination of bits.
5
6.
Arithmetic operationsperformed 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 additionof two or more binary
numbers.
Uses Binary addition rules
7
8.
8
Input 1 Input2 Sum Carry
0 0 0 No carry
0 1 1 No carry
1 0 1 No carry
1 1 0 1
1. Start byadding 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. Add10 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. Add01 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. Add11 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. Add1101 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. Add10111, 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
1. Start bysubtracting 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. Subtract01 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. Subtract01 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. Subtract0111 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 Subtract10010 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. Subtract101111 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 binarynumber 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 signedbinary 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 bitis 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 rangefor 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 incomputer for simplification of
subtraction operation.
Two types of complements
1’s complement, and
2’ s complement.
27
Binary numbercan 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 waysof representing position of
binary point in a register
Fixed Point Number Representation, and
Floating Point Number Representation.
31
32.
Assumes binarypoint 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 Magnituderepresentation
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 01 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 magnitudeand 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 positivenumber 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 outputis 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. Addbinary +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. Addbinary -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. Addbinary +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. Addbinary -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 toaddition of two signed numbers.
Sign of second number is changed before
performing the addition operation.
42
Uses tworegisters
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 symbolsin 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
EBCDIC standsfor 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 standsfor American Standard Code
for Information Interchange
Two types of ASCII codes
ASCII-7 and
ASCII-8.
50
51.
Standard ASCIIcode.
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 versionof 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 coderepresents 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 characterencoding 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 withASCII-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