Cognitive Scaffold

Preparing your thinking workspace

arrow_back_ios_new
MENTAL MODEL · M0261

Off-by-one Error

Off-by-one Error
StructureHigh supportLogic
Included
account_tree

Version 1.0.0 · Updated 2026-07-28

CORE DEFINITION

An off-by-one error (OBOE) is an error in counting where the result is one more or one less than it should be due to a mistake in judging boundary conditions. It typically refers to a programming error in which a loop iterates one time too many or one time too few, and is a type of logical error. For example, a programmer might use "less than" instead of "less than or equal to" in a loop comparison, or fail to account for a sequence starting at 0 rather than 1 (as is the case with array indices in many programming languages). This error also occurs in mathematics.

SCAFFOLDING EFFECT

psychology

Reduce cognitive load

An off-by-one error (OBOE) is an error in counting where the result is one more or one less than it should be due to a mistake in judging boundary conditions. It typically refers to a programming error in which a loop iterates one time too many or one time too few, and is a type of logical error. For example, a programmer might use "less than" instead of "less than or equal to" in a loop comparison, or fail to account for a sequence starting at 0 rather than 1 (as is the case with array indices in many programming languages). This error also occurs in mathematics.

anchor

Anchor fast decisions

In counting, indexing, and boundary handling, a deviation in the starting/ending point (e.g., counting from 0 vs. 1) leads to a result that is off by one. The root cause is confusion between "interval endpoints" and "counting" (the number of posts equals the number of intervals plus one).

MINIMUM ACTION

In progress 0/4

Practice this model in one real situation:

Check to track your progress (stored locally)
Learning progress0%
account_treeGenealogyexpand_more
menu_bookReferencesexpand_more

Source support: Explicit

  • link
    zh.wikipedia.orghttps://zh.wikipedia.org/wiki/%E5%B7%AE%E4%B8%80%E9%94%99%E8%AF%AFZH · Explicit
    verified

RELATED MODELS