Q Format Explained: Q15, Q31 and Q16.16 Numbers
Learn what Q15, Q31 and Q16.16 mean, how a stored integer maps to a real value, and how to compute the range and resolution of any Q format in C.

You will meet the names Q15, Q31 and Q16.16 in datasheets, in DSP libraries and in other people's firmware, usually with no explanation. They are all the same idea: a way to store a number with a fractional part in an ordinary integer, with no floating-point hardware. The Q names tell you where the invisible binary point sits, and once you can read them you can predict a format's range, its resolution and what multiplying two of them does. This post explains the notation from scratch, defines the two naming conventions you will run into, and gives you a C program that prints the range and resolution of any format. It assumes you know binary numbers and two's complement. It is the notation reference for the fixed-point guide, where the arithmetic operations built on top of it are covered.
The definitions follow the conventions used by Arm's CMSIS-DSP library, documented in the CMSIS-DSP reference, with the Texas Instruments convention noted where it differs.
A number with an invisible point
Write 6.75 in binary and you get 110.11: the digits after the point stand for halves and quarters, as the digits after a decimal point stand for tenths and hundredths. A computer register has no place to store a point, only bits. The solution is to remove the point and remember where it was. Store 11011 as the integer 27, and keep the knowledge that the lowest two bits are fractional, so the real value is 27 divided by 4, which is 6.75.
That knowledge is the Q format. A number in a format with n fractional bits is the stored integer divided by 2^n. Nothing in the hardware or the compiler records n; it lives in your head, your comments and your type names. Every operation in a fixed-point program is a decision about what n the result has.
Reading the notation
A Q format is written Qm.n or Qn. The letters and numbers describe how many bits go where.
In the Arm convention, which this site uses, Qn means a signed number with n fractional bits, stored in a word whose size is stated or implied by the type. Q15 is a 16-bit signed integer with 15 fractional bits. Q31 is a 32-bit signed integer with 31 fractional bits. Q7 is an 8-bit signed integer with 7 fractional bits. In each, the single remaining bit is the sign, so these formats hold only values from minus 1 up to a little under plus 1.
When there is an integer part, the notation Qm.n gives m integer bits and n fractional bits, with the sign bit in addition, so Q16.16 is 1 + 16 + 16 = 33 bits in a strict reading. In practice firmware uses Q16.16 to mean a 32-bit word with 16 integer bits including the sign and 16 fractional bits, and Q8.8 for a 16-bit word with 8 and 8. The word size is what matters, so always state it in a comment or a type name.
The Texas Instruments convention counts the sign bit among the integer bits. Their Q1.15 is the Arm Q15, and their Q0.15 would be an unsigned 15-bit fraction. When you read a TI document, add the sign bit when you translate: TI Q1.15 equals Arm Q15, and TI Q1.31 equals Arm Q31. The risk is only in reading, since the stored bits are identical.
What a stored value means
The mapping is the same for every format. For a signed word of w bits with n fractional bits:
the real value is
stored / 2^nthe smallest step, the resolution, is
1 / 2^nthe most negative value is
-2^(w-1-n)the largest value is
(2^(w-1) - 1) / 2^n, short of2^(w-1-n)by one step
A short program turns those formulas into a table, which saves doing the powers of two by hand:
#include <stdio.h>
static void qinfo(const char *name, int word_bits, int frac_bits)
{
double scale = (double)(1ULL << frac_bits);
double min = -(double)(1ULL << (word_bits - 1)) / scale;
double max = (double)((1ULL << (word_bits - 1)) - 1) / scale;
printf("%-7s min %15.9f max %15.9f step %.9f\n", name, min, max, 1.0 / scale);
}
int main(void)
{
qinfo("Q7", 8, 7);
qinfo("Q15", 16, 15);
qinfo("Q8.8", 16, 8);
qinfo("Q16.16", 32, 16);
return 0;
}Q7 min -1.000000000 max 0.992187500 step 0.007812500
Q15 min -1.000000000 max 0.999969482 step 0.000030518
Q8.8 min -128.000000000 max 127.996093750 step 0.003906250
Q16.16 min -32768.000000000 max 32767.999984741 step 0.000015259Read the pairs. Q7 and Q15 are the same idea at two sizes: both span almost minus one to plus one, and Q15 has 256 times finer steps. Q8.8 and Q16.16 trade range against resolution inside one word: Q8.8 reaches 128 and steps in 0.0039, while Q16.16 reaches 32,768 and steps in 0.000015, because it has twice the bits. For a given word size, every bit you give to the integer part is a bit taken from the fraction, and the range doubles as the resolution halves.
What the bits look like
The stored bits are an ordinary two's complement integer. To see them, print a few Q15 values in binary:
#include <stdint.h>
#include <stdio.h>
static void show(double real, int16_t q)
{
printf("%6.2f = %6d = ", real, q);
for (int bit = 15; bit >= 0; bit--) {
putchar(((uint16_t)q >> bit) & 1 ? '1' : '0');
if (bit == 15)
putchar(' ');
}
putchar('\n');
}
int main(void)
{
show(0.75, 24576);
show(0.5, 16384);
show(0.25, 8192);
show(-0.5, -16384);
show(-1.0, -32768);
return 0;
} 0.75 = 24576 = 0 110000000000000
0.50 = 16384 = 0 100000000000000
0.25 = 8192 = 0 010000000000000
-0.50 = -16384 = 1 100000000000000
-1.00 = -32768 = 1 000000000000000The first bit is the sign. The remaining 15 bits are the fraction, where the leftmost fractional bit is worth a half, the next a quarter, then an eighth. So 0.75 is a half plus a quarter, bits 11 followed by zeros, which is 0x6000, or 24,576. The negative values are two's complement, so minus 0.5 is 0xC000, which is 65,536 minus 16,384 read as a signed 16-bit number. Minus 1 is the single bit 0x8000, the most negative value, which has no positive partner. That asymmetry, one more negative value than positive, shows up in every signed integer format, and it is the reason -1 * -1 overflows in Q15.
Why choose each format
Different formats suit different data.
Q15 and Q31 are for normalized quantities: audio samples, filter coefficients, sine and cosine values, and ratios. Anything that naturally lives between minus one and one fits, and the multiplication of two such numbers cannot grow beyond one, so there is no overflow except at the one corner. Q15 matches the 16-bit samples of most audio and ADC paths; Q31 gives the extra precision that filters and accumulators want.
Q16.16 is for quantities with a real-world range and moderate precision: positions in a 3D engine, times in seconds with fractions, scale factors that can exceed one. It is the classic choice for 32-bit machines and graphics code because it multiplies and divides with a 64-bit intermediate and no tricks.
Q8.8 and Q24.8 are for cases where you need a little fraction on top of a larger integer: a temperature in degrees with a quarter-degree resolution, or a percentage with a fraction.
A decision method that always works: find the largest absolute value the quantity reaches, count the bits for it (that is m), then give every remaining bit of the word to the fraction. If the resolution that leaves is not fine enough, use a wider word.
Mixing formats
Operations on Q numbers follow from the definition. Adding two numbers requires the same n. Multiplying a number with a fractional bits by one with b gives a result with a + b fractional bits, so a Q15 times a Q15 has 30 fractional bits before you shift. Dividing subtracts the counts. The common mistake is to forget the shift after a multiply and use a number that has twice the fractional bits it should have, which makes every value too large by a factor of 32,768.
When you read code that uses Q formats, look for the shift constant after a multiply. A >> 15 after a product of two 16-bit values says the product of two Q15 numbers is being returned as Q15. A >> 16 after a product of two 32-bit values says Q16.16. The shift is the format written in code.
Check your reading
| Stored value | Format | Real value |
|---|---|---|
| 16384 | Q15 | 0.5 |
| 16384 | Q8.8 | 64.0 |
| 16384 | Q16.16 | 0.25 |
| -32768 | Q15 | -1.0 |
| 98304 | Q16.16 | 1.5 |
| 640 | Q8.8 | 2.5 |
The first three rows are the same stored integer under three formats, and they mean three different numbers: 16,384 divided by 32,768, by 256 and by 65,536. This is why a fixed-point value with no format attached is meaningless, and why naming variables with their format, such as gain_q15, is worth the keystrokes.


