Q7 is a one-byte fixed-point format for compactly representing fractional values from approximately −1 through 1. Seven bits encode the value and one sign bit encodes its sign. Unlike floating-point numbers, its decimal position stays fixed, trading accuracy for smaller storage. section 5.5
Conversions scale values by 128. Inputs at or above 1.0 become Q7(127), while inputs at or below −1.0 become Q7(−128); values inside the range are scaled and stored as i8. Converting back multiplies the stored integer by 2⁻⁷. f32 conversions pass through f64.
Check the representation
Run cargo test to verify f32-to-Q7 conversion, Q7-to-f32 conversion, and out-of-bounds saturation.
