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.
Activity Over Time
Top Contributors
Keywords
Sample Comments
What are the functional equivalents of off-by-one?
You forgot "Off by one errors."
You're my man! The only complaint is array index starts with 1. Can we break backwards compatibility please and make it 0?
Easy answer: the index of arrays doesn't start at 0
Reading through the docs, looks like they have 1-indexed arrays..?
Negative indices are bug-prone. If you mess up iteration bounds, you should get an error, not silent incorrect indexing.
Mind your off-by-1s: 97 items is not large, 98 is.
Maybe... or maybe it's got the same off-by-one error from the StackOverflow answer it's parrotting?
zero-based indexing giving you an 'off by one' problem?
The scourge of the off-by-one error strikes again.