You are here

Number System Representation

Data representation

1.    Unsigned Magnitude Representation

2.    Signed Magnitude

3.    1’s Complement

4.    2’s Complement

1.    Unsigned Number Representation

In this representation all the bits represent only the magnitude of the number without consideration to the sign of the number.

Example:

D7
D6
D5
D4
D3
D2
D1
D0
Value
Minimum Value
0
0
0
0
0
0
0
0
0
Maximum Value
1
1
1
1
1
1
1
1
2N-1 =255

 

The range of the numbers that can be represented in this representation is 0 to 2N-1

For 1 4-bit number the range will be = 0 to 24-1             = 0 to 15

For an 8-bit number the range will be = 0 to 28-1           = 0 to 255

·         Note: We cannot represent signed number in this representation.

Signed and Magnitude number Representation:

We have only +ve or the –ve numbers. Two states can be represented by only a single bit. For convenience and also as standard we take the MSB as ‘0’ to mean +ve and ‘1’ to mean –ve.

In this representation we can represent the signed numbers i.e. both +ve and –ve numbers can be written. Example

D7

(Sign Bit

D6
D5
D4
D3
D2
D1
D0
Value
Min +ve Value
0
0
0
0
0
0
0
0
0
Max +ve Value
0
1
1
1
1
1
1
1
+2N-1  – 1 = + 127
Max –ve Value
1
0
0
0
0
0
0
0
-0
Min –Ve value
1
1
1
1
1
1
1
1
– 2N-1  – 1 =-127

 

The range of numbers in signed and magnitude representation is

+/- 0 to +/- 2N-1  – 1

For 8-bit number N=8, therefore range of numbers will be: +/- 0 to +/- 127

1’s and 2’s Complement Representation:

These representations are well suited for use in computer systems. They provide very powerful representation of signed numbers and their arithmetic operations. It is worth noting that both addition and subtraction are performed using addition only.

1’s Complement Representation:

This representation uses an additional bit generally the MSB, as the sign bit. All the other bits represent the magnitude of the number. Positive numbers are represented by appending a ‘0’ at the MSB position, negative numbers are represented by taking the bitwise complement of the number.

There are two ways of representing the –ve numbers

Bitwise complement
By subtraction Method
Example:

+25 in 8-bit     =    00011001

To write -25, complement each bit of +25

So, -25 in 1’s complement = 11100110

Example:

+25 in 8-bit     =    00011001

To write -25, Subtract it from all 1’s

11111111

-00011001

—————————–

-25    =11100110

So, -25 in 1’s complement = 11100110

Example

Positive Decimal numbers

 

1’s Complement  representation of + numbers 5-bits (MSB sign bit and rest 4 bits to represent 0 to 9
Negative Decimal numbers

 

1’s Complement Representation of  –ve  numbers 5-bits (MSB sign bit and rest 4 bits to represent 0 to 9
0
00000
-0
11111
1
00001
-1
11110
2
00010
-2
11101
3
00011
-3
11100
4
00100
-4
11011
5
00101
-5
11010
6
00110
-6
11001
7
00111
-7
11000
8
01000
-8
10111
9
01001
-9
10110

Range of Numbers in 1’s Complement

In General the range of representable numbers is:  +/- 0 to +/- 2N-1 -1

·         There are two zeros +0 and -0 in this representation. This being disadvantage.

2’s Complement Representation:

This representation also uses an additional bit, generally the MSB, as the sign bit. All the other bits represent the magnitude of the number. Positive numbers are represented by appending a ‘0’ at the MSB position, negative numbers are represented by taking the bitwise complement of the number and adding 1 to it.

There are two ways of representing the –ve numbers

2’s Complement Representation of –ve Numbers
Bitwise complement and adding ‘1’ By subtraction Method and adding ‘1’
Example:

+25 in 8-bit     =    00011001

To write -25, complement each bit of +25

1’s 1’s complement of 25 = 11100110

Add ‘1’                                             +1

—————————————————–

So, -25 in 2’s Complement =1110111

Example:

+25 in 8-bit     =    00011001

To write -25, Subtract it from all 1’s

11111111

-00011001

—————————–

-25    =11100110   , 1’s complement

Add ‘1’           +1

———————————

= 11100111

 

So, -25 in 2’s Complement =1110111

Example

Positive Decimal numbers

 

1’s Complement  representation of + numbers 5-bits (MSB sign bit and rest 4 bits to represent 0 to 9
Negative Decimal numbers

 

1’s Complement Representation of  –ve  numbers 5-bits (MSB sign bit and rest 4 bits to represent 0 to 9
0
00000
-0
00000
1
00001
-1
11111
2
00010
-2
11110
3
00011
-3
11101
4
00100
-4
11100
5
00101
-5
11011
6
00110
-6
11010
7
00111
-7
11001
8
01000
-8
11000
9
01001
-9
10111

 

Range of Numbers in 2’s Complement

In General the range of representable numbers is:  0  to +  2N-1 -1  and  -1 to -2N-1

Example: For an 8-bit number the range will be

Positive Numbers 0 to 28-1 -1   =  0 to 127

Negative Numbers -1 to 2N-1   =    -1 to -128

Representation of Real  Numbers:

Real numbers can be represented using the following two representations.

·         Fixed point Notation

·         Floating point notation

Fixed Point Notation:

In the fixed point notation the decimal point is fixed so that there are fixed number of digits after the decimal point.

It has the following parts

Integer Part

Decimal Point

Fraction Part

The general format of in this notation is:

IIIII…….II . FFFF    (Decimal point fixed at four places from right

Where I is Integer part and F means the fraction part

Example

Represent +45.525 in the fixed point notation.

Solution: Assuming the decimal point to fixed at four decimal places.

Range in Signed Fixed Point Notation

-(2N-1 -1) to  (2N-1 -1) for N-bits

Example:

Represent -50.675 in fixed point with 1 sign bit, 16 bit integer and 15 bit fraction part.

Solution:

Convert to decimal:

50 = 0000000000110010

.675 = 101011001100110

So -50.675 = 1 0000000000110010 . 101011001100110

Floating Point Notation.

This notation is the scientific notation. It does not reserve specific number of bits to the integer or the fraction part of the number. Instead the decimal point is floating.

It has the following Parts.

Sign Bit

Exponent

Mantissa

The number is represented in the following format.

(-1)s (1+M)x2E-bias.

Where S is sign bit of Mantissa

E is exponent value

Example

Represent -53.5 in floating point notation assuming 8 bit exponent, 1 sign bit, 23 bit mantissa

53 in binary = 110101

.5 = .10000

53.5 = 110101.1

= -1.101011 x 25.

IEEE Floating Point Number Representation

Half Precession ( 16 bits== 1 Sign bit, 5 bit exponent, 10 bit mantissa)

Single Precession (32 bits== 1 Sign bit, 8 bit exponent, 23 bit mantissa)

Double Precession (64 bits== 1 Sign bit, 11 bit exponent, 52 bit mantissa)

Quadruple Precession (128 bits== 1 Sign bit, 15 bit exponent, 112 bit mantissa)

Summary of Range of Numbers:

Representation System
General Case
Example for 8-bit Number
Unsigned Magnitude representation
0 to 2N -1
0 to 255
Signed and Magnitude Representation
+/- 0 to +/- 2N-1 -1
+0 to +127

-0 to -127

1’s Complement Representation
+/- 0 to +/- 2N-1 -1
+0 to +127

-0 to -127

2’s Complement Representation
0 to + 2N-1 -1

-1 to – 2N-1

0 to + 127

-1 to -128

Leave a Reply

Top
error: Content is protected !!