Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

two-bit saturating counter

A tiny counter from 0 to 3 that moves up when a branch is taken and down when not; it guesses taken at 2 or 3, so one surprise doesn't flip its guess.

A two-bit saturating counter has states 0-3 (strongly not taken, weakly not taken, weakly taken, strongly taken), increments on taken and decrements on not taken without wrapping, and predicts taken in states 2 and 3; a single anomalous outcome changes the prediction only from a weak state.

Examples

  • States 0 and 1 predict not taken, 2 and 3 taken. A loop's one exit moves a counter at 3 only to 2, so the next pass is still predicted taken.

Read the full section →