Skip to content
Design Corner Knowledge Base ← Back to designcorner.co.ke
Knowledge Base

Software and Development

Fencepost Error

Also known as: Off-By-One Error

1 min read Updated November 10, 2026

Definition A fencepost error is a counting mistake where a result is one too many or one too few.

What it is

The name comes from fences: a fence with ten sections needs eleven posts. Programmers make the same slip when counting items or starting loops at the wrong number.

Why it matters for your business

These bugs cause missing rows, wrong totals or crashes at the end of a list, and they are easy to overlook in testing.

Real-world example

A monthly report leaves out the first customer in the list because the code began counting at one instead of zero.

Design Corner tip

Always test the first and last items in any list or report when checking new software.