liveBook · Manning

Bit

As explained in Learn Rust in a Month of Lunches

A bit is a binary digit representing one of two possible values in digital computation.

A bit is one place in a binary number. It can be 0 or 1—nothing else. A 0 means that place does not count toward the number; a 1 means it does. section 1.3

Each place is worth twice as much as the place to its right. Eight bits make one byte. In Rust, the number in an integer type’s name tells you its size in bits: `u8` has eight bits, while `u16` has sixteen. section 1.3

What eight bits can hold

The largest value a `u8` can hold is 255. More bits allow an integer type to hold larger numbers: a `u16` can hold up to 65,535. section 1.3

How Learn Rust in a Month of Lunches covers it

How deep it goes
Defines bit values and doubling place values, without going into hardware internals.
Examples
Compares decimal place values with eight binary places and gives maximum values for `u8` and `u16`.
What it assumes
Introduces binary from zero using familiar decimal numbers as a comparison.
What you can do after
Evaluate/understand how an integer type’s bit count relates to its size and range.
How it connects
Connects bits to binary, bytes, and signed and unsigned integer types.

Also explained in

Compare how 5 books explain bit →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Rust in a Month of Lunches. The section links point to the parts of the book it draws on.