Off-by-One Errors

Comments discuss off-by-one errors in programming, focusing on array indexing conventions like zero-based vs one-based, negative indices, and related bugs in loops and slicing.

📉 Falling 0.3x Programming Languages
2,406
Comments
20
Years Active
5
Top Authors
#3805
Topic ID

Activity Over Time

2007
5
2008
9
2009
32
2010
49
2011
97
2012
86
2013
118
2014
76
2015
88
2016
149
2017
146
2018
131
2019
127
2020
203
2021
239
2022
267
2023
269
2024
129
2025
178
2026
8

Keywords

MODDED df.loc StackOverflow IMO SET GET NextIndex i.e MRI array index indexing slice length indices indexes negative elements arrays

Sample Comments

PeterisP • Aug 15, 2014 • View on HN

What are the functional equivalents of off-by-one?

tracker1 • Nov 17, 2025 • View on HN

You forgot "Off by one errors."

RomanPushkin • Nov 20, 2022 • View on HN

You're my man! The only complaint is array index starts with 1. Can we break backwards compatibility please and make it 0?

_blk • Sep 11, 2023 • View on HN

Easy answer: the index of arrays doesn't start at 0

typon • Aug 9, 2018 • View on HN

Reading through the docs, looks like they have 1-indexed arrays..?

Mikhail_K • Jan 20, 2021 • View on HN

Negative indices are bug-prone. If you mess up iteration bounds, you should get an error, not silent incorrect indexing.

vages • Nov 23, 2025 • View on HN

Mind your off-by-1s: 97 items is not large, 98 is.

couchand • Jul 5, 2023 • View on HN

Maybe... or maybe it's got the same off-by-one error from the StackOverflow answer it's parrotting?

tomsaffell • May 10, 2016 • View on HN

zero-based indexing giving you an 'off by one' problem?

whamill • Apr 13, 2012 • View on HN

The scourge of the off-by-one error strikes again.