7

I have some misunderstandings with Q format. Please help me in understanding this.

  • If I say Q8 [unsigned] then there will be $8$ fractional bits. Is it ? How can I represent a $1$ and $1.5$ in this case?

  • If I say Q8 [ signed ] then there will be $1$ sign bit and $7$ fractional bits. Here how can I represent a $1$ and $1.5$?

  • When I say Q1.7 means I have $1$ integer bit and $7$ fractional bits. And the minimum number I can store in Q1.7 is $-1$ and maximum number is $1-1/2^7$. Is this understanding is correct ?

Gilles
  • 3,386
  • 3
  • 21
  • 28
rajez79
  • 357
  • 2
  • 7
  • 13

1 Answers1

7

I prefer to use a more explicit notation that consists of the number of integer and fractional bits, like in your last question. I'll take them one at a time:

  1. By Q8, I assume you mean unsigned Q0.8 (no integer bits, 8 fractional bits). In this format, there is no representation for the numbers $1.0$ or $1.5$. The largest value that an 8-bit unsigned integer can hold is $255$, which in this representation would correspond to a fixed-point value of $\frac{255}{256} = 0.9961$.

  2. Similarly to the above, in signed Q0.7 format, there is no representation for $1.0$ or $1.5$. The largest 8-bit signed number is $127$, which would represent $\frac{127}{128} = 0.9922$.

  3. You need to be explicit about whether your number is signed or unsigned. If you have a signed Q1.7 format, that would imply that your values are 9 bits long (1 sign bit, 1 integer bit, 7 fractional bits), which is unlikely. However, assuming that you had such a 9-bit signed number with 1 integer bit and 7 fractional bits, you can represent fixed-point numbers in the range $-2$ to $(2 - 2^{-7})$.

    Recall that the conversion between the integer value and the corresponding fixed-point representation is merely a division by two raised to the number of fractional bits. A 9-bit signed integer can hold values in the range $-256$ to $255$, which leads to the fixed-point range I described above.

Jason R
  • 24,595
  • 2
  • 67
  • 74