Fixed-point converter
Float ↔ fixed in any Q-format. Pick a word width and Q-factor — the integer-bits exponent E, the value range and the LSB follow — then convert a value with your choice of rounding and saturation.
The Q-format
For a signed N-bit type the Q-factor (fractional bits) and the
integer-bits exponent E satisfy E = (N − 1) − Q. Edit
either field — the other follows.
Convert a value
Bulk mode (comma- or whitespace-separated)
What the result means
- Range: the smallest and largest float values the format can represent.
- LSB:
2−Q— one integer step expressed as a float. - 1.0 ↔ int:
2Q— the integer that represents 1.0, useful when reading raw memory dumps. - Conceptual integer:
round(x · 2Q)before saturation. May be outside the type's range. - Saturated integer: clamped to
[−2N−1, 2N−1−1]. The SAT flag indicates whether saturation actually fired. - Hex: two's-complement representation in
Nbits (matches what you'd see in a memory dump). - Round-trip: the saturated integer divided back
by
2Q. - Error / LSBs:
round-trip − x, both as a float and as a multiple of the LSB (2−Q).