161k views
1 vote
What's the formula to determine the maximum storage of a positive/negative number in twos complement?

User Buzkall
by
7.3k points

1 Answer

6 votes

Final answer:

The formula to determine the maximum storage of a positive/negative number in two's complement involves subtracting 1 from the maximum positive number and calculating the two's complement for the maximum negative number.

Step-by-step explanation:

The formula to determine the maximum storage of a positive/negative number in two's complement is as follows:

  1. For a positive number, subtract 1 from the maximum positive number that can be represented in the given number of bits. This will give you the maximum positive number.
  2. For a negative number, calculate the two's complement of the maximum positive number. This can be done by inverting all the bits of the maximum positive number and then adding 1 to the result. The resulting number will be the maximum negative number that can be represented in the given number of bits.

For example, in an 8-bit system, the maximum positive number is 01111111 (127 in decimal). Therefore, the maximum negative number can be calculated as follows:

Inverting all the bits: 10000000

Adding 1 to the result: 10000001 (-127 in decimal).

User Amine KOUIS
by
8.7k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.

9.4m questions

12.2m answers

Categories