Thursday, February 28, 2013




Numbers are not necessarily stored in a computer with perfect precision. Each number is allowed only a certain number of bits for storage.

Usually integers are stored accurately with a limited range. Real numbers are stored with a large range but less accuracy (using floating-point representation).


Positive integers

As the numbers are all positive no sign bit is necessary.

The largest number which can be stored in a register with n bits is 2n – 1.

The smallest number which can be stored is 0 .


For an eight-bit word the largest number possible = 111111112

=1000000002-1=28-1 (=255)

Twos complement integers

If twos complement integers are represented in a register or location of n bits, then the largest positive number possible = 2n -1-1

the most negative number possible = -2n -1-1


For an eight-bit word the largest number possible =01111111 (as the first bit is a sign bit)

=27-1 (=127)

The most negative number

=100000002 (first bit=1 to get a negative number; as we are complementing negative numbers, the other bits should be as small as possible i.e. 0)

This represents -(11111112+ 1) (Taking twos complement)

= -100000002

= -27 (=-128)

i.e. The range of twos complement integers in an eight-bit register is -128 to 127

Worked question

Binary integers are represented using twos complement notation in a 16-bit register. Find their range.

Largest positive integer is 01111111111111112=215-1

= 32 767

Most negative integer is 1000 0000 0000 00002 = -(111 1111 111111112+ 1)

= -1000 0000 0000 0000


= -32768

i.e. The integers represented. lie in the range -32 768 to +32 767 inclusive