0

I am studying $\rm Q$ number formats and in a few places it's used to represent $2$'s complement fixed point numbers , and other places it's used to represent unsigned fixed point numbers. Given a $\rm Q$ number e.g $\rm Q1.4$:

  • How do I know if it's a signed or unsigned number ?
  • Should it be given that it's used in a signed or unsigned context?
Gilles
  • 3,386
  • 3
  • 21
  • 28
BubbleBoy
  • 3
  • 1

1 Answers1

2

From the name of the format alone ("Qm.n") you generally can't tell if the numbers are signed or unsigned. There is a convention that would use a prefix "U" to indicate that the numbers are unsigned, but that's not used universally. Often when the numbers are signed, the sign bit would not be included in the number m, so by comparing the register size with the sum m+n you could figure out if there's an extra sign bit or not. But that's also not a 100% indication because sometimes the sign bit is included in the number m, so m+n equals the register size, but the numbers are signed.

So in general you need extra information to be sure if the numbers are signed or not. In some cases, you can get a hint from comparing the register size with the sum m+n.

Matt L.
  • 89,963
  • 9
  • 79
  • 179