Fixed-Point Q-Format Converter

Enter a value and the number of fractional bits to convert to or from Q-format fixed point.

How it is calculated

With n fractional bits the scale is 2n. In the real-to-fixed mode the stored integer is raw = round(value × 2n), the value it represents is real = raw ÷ 2n, and the quantization error is value − real. In the fixed-to-real mode the number you type is taken as the raw integer (rounded to a whole number if it has decimals), and the error is zero. The resolution is the size of one step, 1 ÷ 2n. The number of fractional bits must be a whole number from 0 to 62, and results whose raw integer is too large to show exactly are refused. Halves round away from zero. The tool does not apply a word length, so it does not clip or wrap values to 16 or 32 bits.

Worked example

Convert 0.3 to a Q15 format (15 fractional bits). The scale is 215 = 32,768, and 0.3 × 32,768 = 9,830.4, which rounds to a raw integer of 9,830. Converting back, 9,830 ÷ 32,768 = 0.29998779. The error is 0.3 − 0.29998779 = 0.0000122070, well inside the step size (resolution) of 0.0000305176. The firmware would store 9830 and treat it as approximately 0.3.

Try this example →

Common mistakes

  • Typing the raw integer while the mode is real-to-fixed (or the real value in fixed-to-real mode). 9830 in real-to-fixed mode is scaled again to a raw of 322,109,440.
  • Confusing the fractional bit count n with the total word length. Q15 or Q1.15 uses n = 15; the sign bit and the word size are not asked for here.
  • Forgetting the range limit of your word. The tool does not clip: a value of 2 with 15 fractional bits gives raw 65,536, which does not fit in a signed 16-bit register (largest 32,767).
  • Expecting an exact conversion. Most decimals such as 0.3 are not multiples of the resolution, so a small non-zero error is normal, and it can be negative.
  • Entering a fractional bit count with decimals or above 62. Values such as 2.5, -1 or 63 give no result.

About this calculator

Q-format (Qm.n notation) represents a real number as a fixed-point integer by reserving n bits for the fractional part: the stored raw integer equals the real value multiplied by 2ⁿ, so a Q15 (Q1.15) value in a 16-bit word has a resolution of 1/2¹⁵ ≈ 0.0000305 and a range of roughly −1 to 0.99997. Converting a real number to Q-format means rounding value × 2ⁿ to the nearest integer, which introduces quantization error equal to the difference between that rounded integer (scaled back) and the original value.

Embedded-systems and DSP (digital signal processing) engineers use Q-format on microcontrollers and DSP chips without a hardware floating-point unit — common in audio codecs, motor-control firmware, and older ARM Cortex-M and TI TMS320 designs — because fixed-point arithmetic runs faster and more predictably than software-emulated floating point. This calculator converts either direction and reports the resolution and rounding error so firmware developers can judge whether a given bit width is precise enough for their signal chain.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    To pick the number of fractional bits, start from the precision you need: the resolution is 2 to the power of minus n, so a step of 0.001 or finer needs at least 10 bits (about 0.00098). Whatever is left of your word length, minus one sign bit, is what remains for the integer range. What word length are you targeting, 16 or 32 bits?

Popular calculators

All Calculators