🔢 Fixed-Point (Q-format) Converter

Convert float ↔ Qm.n fixed-point, with range, resolution, hex and binary raw value.

Qm.n — e.g. Q1.15 has n=15.

How it works

A Qm.n fixed-point number stores a real value as an integer scaled by 2n, using n fractional bits and m integer bits (plus a sign bit if signed):

raw = round(float × 2n)     float = raw ÷ 2n

The representable range and resolution follow directly from the bit widths. Values outside the range are clamped to the nearest representable value, and the quantization error shows how much precision was lost converting to fixed-point.