Computer Oriented Numerical Methods (BCA) 3rd Sem Previous Year Solved Question Paper 2022

Practice Mode:
3.

Differentiate between 1’s complement representation and 2’s complement representation of numbers by taking examples.

Explanation

1's complement and 2's complement are two ways to represent negative numbers in binary, each with its own rules for negation and arithmetic operations.

1's Complement Representation:

In 1's complement representation, negating a number is achieved by flipping all the bits (changing 0s to 1s and vice versa).

Example: Let's represent the decimal number -6 using 4-bit 1's complement.

  1. Convert 6 to binary (4 bits): 0110

  2. To represent -6, negate the binary number by flipping all the bits: 1001

So, -6 in 4-bit 1's complement is 1001.

1's Complement Representation:

In 1's complement representation, negating a number is achieved by flipping all the bits (changing 0s to 1s and vice versa).

Example: Let's represent the decimal number -6 using 4-bit 1's complement.

  1. Convert 6 to binary (4 bits): 0110

  2. To represent -6, negate the binary number by flipping all the bits: 1001

So, -6 in 4-bit 1's complement is 1001.

2's Complement Representation:

In 2's complement representation, negation is achieved by inverting the bits and adding 1.

Example: Let's represent the decimal number -6 using 4-bit 2's complement.

  1. Convert 6 to binary (4 bits): 0110

  2. To represent -6, negate the binary number (flip all bits) and add 1: 1010 + 1 = 1011

So, -6 in 4-bit 2's complement is 1011.

Arithmetic in 2's Complement:

In 2's complement, addition and subtraction can be performed just like regular binary, and there is no need to handle the carry separately.

Example: Let's add -6 (1011) and 3 (0011):

1011 (-6 in 2's complement)

  • 0011 (3 in 2's complement)


1110 (Result)

The result is 1110, which is the 2's complement representation of -2.

1's complement and 2's complement representations are two methods for representing negative numbers in binary, and they differ in how negation is achieved and how arithmetic operations are performed. 2's complement is more commonly used due to its simplicity in arithmetic and the representation of both positive and negative numbers with a single representation of zero.