Fixed-point representation stores fractional numbers as plain integers by agreeing on an implicit scaling factor. It is the workhorse of digital signal processing (DSP), embedded firmware and FPGA designs, where floating-point hardware is expensive or absent. This converter encodes any decimal into a signed Qm.n format and shows you the exact bits.
How it works
A signed Qm.n number reserves:
1sign bit,mbits for the integer part,nbits for the fractional part,
for a total of m + n + 1 bits. To encode a value:
- Multiply the real value by
2^n(the scaling factor). - Round to the nearest integer — this is the stored integer.
- Interpret that integer as a two’s-complement number of
m + n + 1bits.
To decode, you divide the stored integer by 2^n. The smallest representable step (resolution) is 2^-n, and the representable range is [-2^m, 2^m - 2^-n].
Common fixed-point formats in practice
Some formats appear repeatedly in DSP and embedded work:
| Format | Integer bits (m) | Fractional bits (n) | Total bits | Typical use |
|---|---|---|---|---|
| Q1.15 | 1 | 15 | 17 | Audio DSP on 16-bit DSPs; range -1.0 to ~1.0 |
| Q0.31 | 0 | 31 | 32 | High-precision fractional values; FIR filter coefficients |
| Q15.16 | 15 | 16 | 32 | General-purpose 32-bit fixed-point; game physics |
| Q8.8 | 8 | 8 | 17 | Pixel blending, simple embedded sensor values |
| Q1.14 | 1 | 14 | 16 | Some ARM CMSIS-DSP filter coefficients |
The notation Qn (without m) is sometimes used to mean Q0.n (all fractional bits, no integer part), and is common in audio contexts where values are normalised to the range -1.0 to +1.0.
Worked example: Q7.8
Encoding 3.14159 in Q7.8 (16 bits total, where m=7 and n=8):
scaled = 3.14159 × 2^8 = 3.14159 × 256 = 804.247
stored = round(804.247) = 804
decoded = 804 / 256 = 3.140625
error = 3.14159 - 3.140625 = -0.000965
hex = 0x0324
binary = 0000 0011 0010 0100
The range of Q7.8 is [-128.0, +127.99609375], so this value fits without overflow. The resolution (smallest step) is 1/256 ≈ 0.00390625.
Worked example: overflow
Trying to encode 200.0 in Q7.8 where the maximum is approximately 127.996:
scaled = 200 × 256 = 51200
max Q7.8 = 2^7 - 2^-8 = 128 - 0.00390625 ≈ 127.996
OVERFLOW — value exceeds representable range
A saturating implementation would clamp to the maximum representable value. The converter flags this condition so you know to widen the format (add more integer bits) or scale your input values.
Choosing m and n
The trade-off is straightforward: more fractional bits (larger n) give finer resolution but a smaller integer range for the same total bit width. More integer bits (larger m) give a wider range but coarser resolution.
For a given word width (say 16 bits), you have 15 bits to split between m and n. A common approach:
- Find the largest value you need to represent. Set m so that
2^mcomfortably exceeds it. - Assign all remaining bits to n for precision.
- Check the resulting resolution (
2^-n) against your accuracy requirements.
If your value exceeds the representable range the tool flags an overflow and clamps the result, mirroring what a saturating fixed-point unit would do. All computation runs locally in your browser.