liveBook · Manning

8-bit signed integer

As explained in Rust in Action: Systems programming concepts and techniques

i8 is Rust's signed 8-bit integer type.

Rust’s i8 type stores a signed value in one byte. Here, it provides the hidden storage for Q7 fixed-point numbers representing values from −1 to 1 compactly, trading accuracy for space. section 5.5

Using i8 inside Q7

The tuple struct Q7(i8) keeps the byte field private while derived traits provide debugging, copying, and equality. Conversion clamps values at Q7(127) and Q7(−128), then scales values through the i8 representation.

How Rust in Action: Systems programming concepts and techniques covers it

How deep it goes
Defines i8 as Q7’s one-byte representation and demonstrates scaling, clamping, derived traits, and conversions.
Examples
Uses Q7(i8), bounded f64 and f32 conversions, and tests for out-of-range values.
What it assumes
Assumes basic Rust syntax while demonstrating tuple structs, derived traits, and From conversions in context.
What you can do after
Builds a compact Q7 value type with i8 storage and conversions from f32 or f64.
How it connects
Connects i8 with fixed-point numbers, quantization, tuple structs, trait derivation, and numeric conversions.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust in Action: Systems programming concepts and techniques. The section links point to the parts of the book it draws on.