0% found this document useful (0 votes)
7 views49 pages

De Lecture - 02

Uploaded by

kaushalk42k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views49 pages

De Lecture - 02

Uploaded by

kaushalk42k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 49

Representation of Signed

Binary Number
1’s Complement
• The 1's complement of any binary number is
performed by simply changing all 1's into 0's
and 0's into 1's, i.e. each bit is replaced by its
complement.
Binary number 1's complement
1011 0100
010101 101010
1100.01 0011.10
10010.110 01101.001
2’s Complement

• The 2's complement of any binary number is


determined by adding 1 to 1's complement of
that number.
• 2's complement of number =
1's complement of a number + 1
Example:
Find the 2's complement of the (1010)2

Solution
Given binary number = 1010
1's complement of 1010 = 0101
+1
0110
2's complement of 1010 = 0110
Example:
Find the 2's complement of the (11.01)2

Solution
Given binary number = 11.01
1's complement of 11.01 = 00.10
+1
00.11
2's complement of 11.01 = 00.11
Binary number: 1010 1111 11.01
2’s complement: 0110 0001 00.11

Note: The 2’s complement of a number can be


obtained by leaving all least significant 0’s and
the first one (1) unchanged, and replacing all
1’s with 0’s and 0’s with 1’s in all higher
significant bits.
REPRESENTATION OF SIGNED NUMBER

• There are two ways of representing signed


numbers
 Sign-magnitude form
 Complement form
There are two complement forms:
 1's complement form
 2's complement form
Sign-magnitude Representation
• The sign-magnitude format for 8-bit signed
number

• Here, the most significant bit (MSB) represents


sign of the number.
• If MSB is 1, number is negative and if MSB is 0,
number is positive.
• The remaining (seven) bits represent magnitude
of the number.
Example: Represent the following signed
number in sign-magnitude form.
(a) 25 (b) – 25 (c) 68 (d) - 68
NOTE: The actual range of numbers we can represent
in sign-magnitude format for n-bit would be
- (2n-1 - 1) to + (2n-1 - 1)
Example:
If we have 8 bits to represent a signed binary
number, (1-bit for the sign bit and 7-bits for
the magnitude bits), then the actual range of
numbers we can represent in sign-magnitude format
would be:
- (28-1 – 1) to + (28-1 – 1)
- (27 - 1) to + (27 – 1)
- 127 to + 127
1's complement Representation
• If the number is positive, the magnitude is
represented in its true binary form and a sign
bit 0 is placed in front of the MSB.

• If the number is negative, the magnitude is


represented in its 1’s complement form and a
sign bit 1 is placed in front of the MSB.
Example: Represent the following signed
number in 1’s complement form.
(a) 25 (b) - 25 (c) 68 (d) - 68
2's complement Representation
• If the number is positive, the magnitude is
represented in its true binary form and a sign
bit 0 is placed in front of the MSB.

• If the number is negative, the magnitude is


represented in its 2’s complement form and a
sign bit 1 is placed in front of the MSB.
Example: Represent the following signed
number in 2’s complement form.
(a) 25 (b) - 25 (c) 68 (d) - 68
Example: Each of the following numbers is a signed
binary number. Determine the decimal value in each
case, if they are in (i) sign-magnitude form, (ii) 2's
complement form, and (iii) 1's complement form.
(a) 01101 (b) 010111 (c) 10111 (d) 1101010
Solution:
Binary Arithmetic's
1. Binary Addition
The rules of binary addition are the following:

0+0=0
0+1=1
1+0=1
1 + 1 = 10, i.e. 0 with a carry of 1
Example: Add the binary numbers
1101.101 and 111.011
Solution
2. Binary Subtraction
The rules of binary subtraction are the
following:
0-0=0
0 - 1 = 1, with a borrow of 1
1-0=1
1-1=0
Example: Subtract the binary number 101
from 1011
Solution
3. Binary Multiplication
The rules of binary multiplication are the
following:
0×0=0
0×1=0
1×0=0
1×1=1
Example: Multiply the binary number 1101
by 110
Solution
4. Binary Division
Example: Divide the binary number 11010 by
101
Solution
Rules of Binary Arithmetic
Binary Arithmetic using 1’s
and 2’s Complements
Logic for Binary Arithmetic
The binary arithmetic operation can be written
as:
A+B=A+B
A – B = A + (-B)
- A + B = (-A) + B
- A – B = (-A) + (-B)
The negative binary number can be represented
either 1’s or 2’s complement form.
Binary Arithmetic using 1’s
Complements
Example-1: Subtract 14 from 25 using 1’s
complement method.
Example-2: Add -25 to 14 using 1’s
complement method.
Example-3: Add -14 to -25 using 1’s
complement method.
Example-4: Add 14 to 25 using 1’s
complement method.
Binary Arithmetic using 2’s
Complements
Example-1: Subtract 14 from 46 using 2’s
complement method.
Example-2: Add -75 to 26 using 2’s
complement method.
Example-3: Add -14 to -25 using 2’s
complement method.
Floating-Point Number
Representation
• Floating-Point is useful for representing a
number in a wide range: very small to very
large.
• It is widely used in the scientific world.
• There are many ways to write a number in
scientific notation, but there is always a
unique normalized representation, with
exactly one non-zero digit to the left of the
point.
Example:
257 = 25.7 × 101 = 2.57 × 102 = …
0.232 × 103 = 2.32 × 102 = 23.2 × 101 = …
01001 = 1.001 × 23 = ...
• What’s the normalized representation of
00101101.101 ?
00101101.101 = 1.01101101 × 25

• What’s the normalized representation of


0.0001101001110 ?
0.0001101001110 = 1.101001110 × 2-4
• We can represent floating-point numbers with
three binary fields:
– a sign bit S,
– an exponent field E, and
– A significand (mantissa) / fraction field F.
• The IEEE 754 standard defines several
different precisions.

 Single precision (32 bits) [1 + 8 + 23]

 Double precision (64 bits) [1 + 11 + 52]

 Extended precision (80 bits) [1 + 15 + 64]


• Single precision numbers include a 1-bit sign,
an 8-bit exponent and a 23-bit fraction, for a
total of 32 bits.

• Double precision numbers have a 1-bit sign,


an 11-bit exponent and a 52-bit fraction, for a
total of 64 bits.
• The sign bit is
0 for positive numbers and
1 for negative numbers.
• The E field represents the exponent as a biased
number.
• It contains the actual exponent plus 127 for single
precision, or the actual exponent plus 1023 in
double precision.
• This converts all single-precision exponents from -
126 to +127 into unsigned numbers from 1 to 254,
and all double-precision exponents from -1022
to +1023 into unsigned numbers from 1 to 2046.
• The field F contains a binary fraction.
• The actual mantissa of the floating-point value
is (1 + F).
– In other words, there is an implicit 1 to the left of
the binary point.
– For example, if F is 01101..., the mantissa would
be 1.01101...
Example: What is the single-precision
representation of 347.625?
• First convert the number to binary:
347.625 = 101011011.1012
• Normalize the number by shifting the binary point until there is a
single 1 to the left:
101011011.101 × 20 = 1.01011011101 × 28
• The bits to the right of the binary point comprise the fraction
field F.
• The number of times you shifted gives the exponent.
• The field E should contain:
exponent + 127 = 8 + 127 = 135 = 100001112
• Sign bit: 0 if positive, 1 if negative.
0 10000111 01011011101000000000000
Example: Express -3.75 as a floating point
number using IEEE single precision.
• First, let's normalize according to IEEE rules:
- 3.75 = - 11.112 = - 1.111 × 21
• Since it is a negative number , so S = 1.
• The bias is 127, so we add 127 + 1 = 128 (this
is our exponent)
E = 128 = 100000002
1 10000000 11100000000000000000000
Example: Find out the floating point number
from the following representation.
0 10000011 00111000000000000000000
0 10000011 00111000000000000000000
E = 100000112 = 131
N = (-1)S × (1 + F) × 2E-bias
= (-1)0 × (1.00111000000000000000000) × 2131-
127

= 1 × (1.00111000000000000000000) × 24
= 1.00111000000000000000000 × 24
= 10011.10
= 19.5
Example: Find out the floating point number
from the following representation.
1 1000 0001 011 0000 0000 0000 0000 0000
1 1000 0001 011 0000 0000 0000 0000 0000
E = 100000012 = 129
N = (-1)S × (1 + F) × 2E-bias
= (-1)1 × (1.01100000000000000000000) × 2129-127
= - 1 × (1.01100000000000000000000) × 2 2
= - 1.01100000000000000000000 × 2 2
= - 101.10
= - 5.5

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy