2
$\begingroup$

What does fixed-point number range represents? Why we use formula $2^a - 2^{-b}$, why minus $2^{-b}$? Where $a$ is number of integer bits, and $b$ is number of fractional bits.

If we have for example $a = 8$ and $b = 2$, don't we have a possibility to represent $2^a + 2^{-b}$ number and so that will represent the range?

$\endgroup$
  • $\begingroup$ yes @OlliNiemitalo I am trying to understand some fundamentals about fixed-point numbers, but some terms and formulas are confusing me. $\endgroup$ – user20705 May 12 '16 at 8:24
6
$\begingroup$

Let's assume that we are dealing with unsigned number types. If you would use all $a+b$ bits for the integer part then the set of possible numbers would be: $$\left\{0, 1, 2, 3, \dots, 2^{a+b}-1\right\}.$$

These numbers can be divided by $2^b$ (or multiplied by $2^{-b}$) to take use of $b$ bits for the fractional part, resulting in this set of possible numbers:

$$\left\{0, 1\times2^{-b}, 2\times2^{-b}, 3\times2^{-b},\dots, \left(2^{a+b}-1\right)\times2^{-b}\right\} \\=\left\{0, 2^{-b}, 2\times2^{-b}, 3\times2^{-b},\dots, \underline{\underline{2^a-2^{-b}}}\right\}.$$

So your formula gives the largest number that can be represented (double underlined).

The formula can also be understood as going a step $2^{-b}$ or one least significant bit (LSB) worth backwards from $2^a$ which is the first number that has the same truncated binary string representation as 0, the first number in the system. In a similar way in the 8-bit unsigned integer system we take a LSB-sized step backwards from 256 (1 0000 0000 binary) to obtain 255 (1111 1111 binary) which is the largest representable number in that system.

I just found out that range has an established meaning in arithmetic: Largest value minus smallest value. The smallest value happens to be zero so in this case the largest value equals the range.

$\endgroup$
5
$\begingroup$

For an unsigned fixed-point, the representation for a $N$-bit binary number $x$ is

$$x=\frac{1}{2^b}\sum_{n=0}^{N-1}2^n x_n, \quad \text{where $x_n$ is the $n^{\rm th}$ bit value of $x$}$$

For this $N$-bit binary number you can get values from $0$ to $2^N -1$ since the smallest number is the $N$-bit all-zeros ($x_n =0\ \forall n$), and the largest is the $N$-bit all-ones ($x_n =1\ \forall n$). The representation for the minimum and maximum values are then given as follow:

\begin{align} x_{\rm min}&=\frac{1}{2^b}\left(1\cdot 0+ 2^1\cdot 0+\ldots+2^{N-1}\cdot 0\right)=\frac{1}{2^b} \cdot 0=0\\ x_{\rm max}&=\frac{1}{2^b}\left(1\cdot 1+ 2^1\cdot 1+\ldots+2^{N-1}\cdot 1\right)=\frac{1}{2^b}\left[1\cdot\left(\frac{1-2^N}{1-2}\right)\right]=\frac{2^N - 1}{2^{b}}=2^{N-b} - 2^{-b}\\ \end{align} With $a=N-b$, you get the range.

You can read this great paper by Randy Yates on Fixed-Point Arithmetic. There you find the derivation of the range for the signed case and much more.

$\endgroup$
2
$\begingroup$

The formula expresses the difference between the largest, and smallest numbers we can represent with an integer/fractional representation.

Consider a simple example, such as 2.2 (where there are 2 integer bits and 2 fractional bits in our fixed point representation).

If we're using two's complement (signed) binary, the largest positive number we can represent is:

01.11

This number is equivalent to $2 - \frac{1}{4}$.

The largest negative number we can represent is:

10.00

This number is equivalent to $-2$.

The total range here is from the largest positive to largest negative, or $-2$ -> $2 - \frac{1}{4}$. Note that this is equal to:

$4 - \frac{1}{4}$, or $2^a - 2^{-b}$ where both $a$ and $b$ are equal to 2, according to our 2.2 representation.

$\endgroup$
  • $\begingroup$ why the largest positive is 3 and 3/4? Why not 4? $\endgroup$ – user20705 May 14 '16 at 17:47
  • $\begingroup$ Because we consider the range to include the value 0. If there are 4 bits, we can represent 16 values. If `zero' is one of these values, and each of the others represents 1/4, we can only add a further $15 * \frac{1}{4}$ to the range. This is why the largest range is 3 and 3/4. To represent 4 (in the binary representation used in this example) you would need to add an extra integer bit. $\endgroup$ – Speedy May 16 '16 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy