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].
Example
Encoding 3.14159 in Q7.8 (16 bits total): multiply by 2^8 = 256 to get 804.24, round to 804. Decoding, 804 / 256 = 3.140625, so the quantization error is about -0.000965. Adding more fractional bits shrinks that error at the cost of integer range.
Notes
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. Choose m and n to balance the magnitude you need against the precision you need.