Multiple choice

The range of integers that can be represented by an n bit 2's complement number system, is

  1. -2n - 1 to (2n -1 - 1)

  2. -(2n -1)to (2n -1 - 1)

  3. -2n - 1 to 2n -1

  4. -(2n +1)to (2n -1 - 1)

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

For example, signed char is 8 bits, we can store from -128 to 127 using sign char.

A two's complement number system encodes positive and negative numbers in a binary number representation. The weight of each bit is a power of two.

The value $w$ of an $N$-bit integer $a_{N-1}a_{N-2}...a_{0}$ is given by the following formula.

$w = -a_{N-1}2^{N-1} + \sum_{i=0}^{N-2}a_i2^i$

The most significant bit determines the sign of the number and is sometimes called the sign bit $-(2^{N-1}$ shown above. Using $N$ bits, all integers from $-2^{N-1}$ to $2^{N-1}-1$ can be represented.