0% found this document useful (0 votes)
3 views2 pages

UNIT-II Data Representation

The document explains integer representation in computers, focusing on unsigned and signed integers, which can be represented using various bit lengths. It details the significance of the most significant bit (MSB) in determining the sign of signed integers and discusses the advantages of using two's complement for negative numbers. Additionally, it provides examples of how integers are represented in different bit lengths, highlighting the unique representation of zero in two's complement.

Uploaded by

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

UNIT-II Data Representation

The document explains integer representation in computers, focusing on unsigned and signed integers, which can be represented using various bit lengths. It details the significance of the most significant bit (MSB) in determining the sign of signed integers and discusses the advantages of using two's complement for negative numbers. Additionally, it provides examples of how integers are represented in different bit lengths, highlighting the unique representation of zero in two's complement.

Uploaded by

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

UNIT-II Data Representation

Integer Representation
Computers use a fixed number of bits to represent an integer. The commonly-used bit-lengths
for integers are 8-bit, 16-bit, 32-bit or 64-bit. Besides bit-lengths, there are two representation
schemes for integers:
1. Unsigned Integers:
These are binary numbers that are always assumed to be positive.
Here all available bits of the number are used to represent the magnitude of the
number. No bits are used to indicate its sign; hence they are called unsigned numbers.
E.g.: Roll Numbers, Memory addresses etc.
Therefore, all positive numbers including zero can be treated as unsigned numbers.

2. Signed Integers:
These are binary numbers that can be either positive or negative.
The MSB of the number indicates whether it is positive or negative.
If MSB is 0 then the number is Positive.
If MSB is 1 then the number is Negative.
Negative numbers are always stored in their 2's Complement form.

Three representation schemes had been proposed for signed integers:


Sign-Magnitude representation
1's Complement representation
2's Complement representation
Table of 3 bit signed number

Number Sign magnitude One’s complement Two’s complement


3 011 011 011
2 010 010 010
1 001 001 001
0 000 000 000
-0 100 (X) 111 (X) 000
-1 101 110 111
-2 110 101 110
-3 111 100 101
-4 --- ----- 100
Negative numbers are stored in 2's Complement form due to two reasons as highlighted above

1. Two's complement gives a unique representation for zero. Any other system gives a
separate representation for 0 and for -0. This is absurd.

In two's complement system, - (x) is stored as two's complement of (x). Applying the
same rule for 0, - (0) should be stored as two's complement of 0. O is stored as 000. So , -
(0) should be stored as two's complement of 0 which again is 000. Hence two's complement
gives a unique representation for 0.

2. It produces an additional number on the negative side. As two's complement system


produces a unique combination for 0, it has a spare combination "100" in the above case,
and can be used to represent - (4)
3 BIT INTEGER
23 = 8 , 𝑡ℎ𝑒𝑟𝑒𝑓𝑜𝑟𝑒 8 𝑐𝑜𝑚𝑏𝑖𝑛𝑎𝑡𝑖𝑜𝑛𝑠
Unsigned signed
0 .........7 -4........-1 ,0,1.......3

4 BIT INTEGER
4
2 = 16 , 𝑡ℎ𝑒𝑟𝑒𝑓𝑜𝑟𝑒 16 𝑐𝑜𝑚𝑏𝑖𝑛𝑎𝑡𝑖𝑜𝑛𝑠
Unsigned signed
0 .........15 -8........-1 ,0,1.......7

5 BIT INTEGER
25 = 32 , 𝑡ℎ𝑒𝑟𝑒𝑓𝑜𝑟𝑒 32 𝑐𝑜𝑚𝑏𝑖𝑛𝑎𝑡𝑖𝑜𝑛𝑠
Unsigned signed
0 .........31 -16........-1 ,0,1.......15

8 BIT INTEGER
28 = 256 , 𝑡ℎ𝑒𝑟𝑒𝑓𝑜𝑟𝑒 256 𝑐𝑜𝑚𝑏𝑖𝑛𝑎𝑡𝑖𝑜𝑛𝑠
Unsigned signed
0 .........255 -128........-1 ,0,1.......127

16 BIT INTEGER
216 = 65536 , 𝑡ℎ𝑒𝑟𝑒𝑓𝑜𝑟𝑒 65536 𝑐𝑜𝑚𝑏𝑖𝑛𝑎𝑡𝑖𝑜𝑛𝑠
Unsigned signed
0 .........65535 -32768........-1 ,0,1.......32767

SIGNED NUMBER EXAMPLE


+5 0101
-5 1011 2’s complement
+9 01001
-9 10111 2’s complement
+23 010111
-23 101001 2’s complement

You might also like