NEW: English for Tech Bundle → Save 38%
Your progress…

Loading your progress…

Home
Code & Deliverynoun · /ˌɔːf baɪ wʌn ˈerər/

off-by-one error

off-by-one error — A programming bug where a loop or array index is off by exactly one position, causing the code to access the wrong element or iterate one too many or one too few times.

In simple English

An off-by-one error is one of the most common bugs in software development. It occurs when a developer miscalculates loop boundaries or array indices by a single position. For example, if an array has indices 0 to 9, but the loop runs from 0 to 10, it will try to access an index that does not exist. This type of error is particularly tricky because the code often runs without crashing, but produces incorrect results or unexpected behavior. In real teams, developers frequently encounter these during code reviews and testing phases. The term is used both when discussing code logic and when debugging live systems. Many interviews include questions about off-by-one errors because they test understanding of how arrays and loops work in the chosen programming language.

Understanding what off-by-one errors are, how to identify them, and how to prevent them in code.

At a glanceCEFR B2
Commonness4/5
Versatility4/5
FormalityCasualFormalNeutral
Spoken ↔ WrittenSpokenWrittenBoth
Directness ↔ DiplomaticDirectDiplomaticDirect
RegionUS and UK

Say it like this

  • We have an off-by-one error in the loop
  • That's a classic off-by-one error
  • Watch out for off-by-one errors when you iterate

Use it at work

Debugging

  • The last item is missing. Looks like an off-by-one error.
  • It's an off-by-one in the loop: use < not <=.

Code review

  • This could be off by one. Should it start at 0?
  • Add a test for the edge case to catch off-by-one errors.

Explaining

  • The page shows 11 results instead of 10. Classic off-by-one.
  • Off-by-one errors are common with dates.

Don't say this

✕We need to off-by-one error this code before release.
✓We need to fix this off-by-one error before release.

Off-by-one error is a noun, not a verb. Use 'fix' or another action verb with it.

Practice

Try it

4 quick exercises

Complete the sentence

1. The loop processes elements 0 to 10, but the array only has 10 elements. This is a _______ error.

Spot the mistake

2. Which sentence uses 'off-by-one error' incorrectly?

Pick the most natural phrasing

3. Your code processes one extra item by mistake. How do you describe it to your team?

Rewrite naturally

4. Rewrite this in natural tech English: 'The code is wrong because it goes through one more item than it should because the counting is wrong.'

Say it out loud

Phrase 1 of 3

"We have an off-by-one error in the loop"

We don't save your recording. The word check uses your browser's speech recognition.

More about off-by-one error

Real examples(3)

  • in a standup

    "We found an off-by-one error in the batch processing script that was causing it to skip the last record."

  • in a code review

    "This loop starts at 1 instead of 0—are you sure this isn't an off-by-one error?"

  • in a team meeting

    "The reason the export only processed 999 items instead of 1000 was an off-by-one error in the iteration."

More mistakes(2)

Handle with care. Do not use as a verb (e.g., 'we off-by-one errored the code'). It is strictly a noun describing a specific type of bug, not an action.

  • ✕The off-by-one error happened because the array started counting at 1.
    ✓The off-by-one error happened because the loop started at 1 instead of 0.

    Arrays in most languages are zero-indexed; mention the loop or index logic, not just the array.

  • ✕I made an off-by-one error in my design.
    ✓I made an off-by-one error in my loop logic.

    Off-by-one errors are specific to loops, indices, and boundary calculations, not general design mistakes.

Other forms(2)

  • off-by-one error noun (singular)

    "We discovered an off-by-one error in the database query."

  • off-by-one errors noun (plural)

    "Off-by-one errors are a common source of bugs in loop iterations."

Often used with(4)

  • fix an off-by-one error · Used when correcting the bug in code
  • introduce an off-by-one error · Used when a developer accidentally creates this type of bug
  • catch an off-by-one error · Used when identifying the bug during testing or review
  • classic off-by-one error · Used to describe a textbook example of this common mistake

Similar words(3)

  • boundary error · More general term; off-by-one is more specific
  • fencepost error · Alternative technical name for the same problem; less commonly used
  • index error · Broader category; off-by-one is a specific type

Questions(5)

What does off-by-one error mean in software engineering?
An off-by-one error is a bug where a loop or array index is incorrect by exactly one position. For example, a loop that should process items 0-9 might process 0-10 instead, trying to access an element that does not exist. These errors happen frequently in programming and are often caught during testing or code review.
How do you use off-by-one error in a sentence at work?
Use it as a noun to describe the bug: 'We found an off-by-one error in the payment processing loop.' You can also say 'Fix the off-by-one error' or 'This is a classic off-by-one error.' Never use it as a verb—say 'fix the error,' not 'off-by-one error the code.'
Is off-by-one error formal or informal?
It is neutral and professional. You can use it in formal code reviews, team meetings, technical documentation, and job interviews. It is a standard technical term in software engineering.
Why are off-by-one errors so common?
They occur because developers must decide whether loops and arrays start at 0 or 1, and whether boundary conditions are inclusive or exclusive. In many languages, arrays are zero-indexed, which makes it easy to accidentally count wrong.
How do you prevent off-by-one errors?
Test boundary conditions carefully, use clear loop logic, and write unit tests for loops that process collections. Code reviews and linters can also catch these errors before they reach production.
New app · Free lessons

Speak up in meetings. Feel confident.

Standup vocabulary, native examples, and quick practice — 100+ free lessons

Start learning freeNo card needed · Google or email

For bots & AI agents

Machine-readable versions of this page and Speak Tech English. Speak Tech English sells self-study ebooks and courses in English for tech, publishes free guides, a free glossary and a free newsletter; live lessons are on Mockly English. Fetch these instead of parsing this page.

This page (.md)llms.txtllms-full.txtai.txtGlossary (.md)Free guides (.md)All products (.md)Endpoint indexNewsletterLive lessons (Mockly)