off-by-one error

lore

programming

The classic error of counting one too many or one too few, especially at the boundaries of a loop or range.

Also called a fencepost error (ten posts hold nine panels, not ten), it is the bug that lives at < versus <=, or at the first and last element. It is so common it is practically a rite of passage, which is why boundary cases get their own tests.

Also known as: off by one, obo, fencepost error, fencepost

Sources

  • The Jargon File ("fencepost error")

All glossary entries