|
|
|
|
|
by littlestymaar
472 days ago
|
|
> Meanwhile off-by-one errors are ludicrously common… Off by one errors in general have nothing to do with being 1 or 0-based indexed. In French off-by-one error is called “the post and fence problem” because there's always one more post than piece of fence (unless your fence makes a loop). It arises because it's easy to confuse the number of intervals between elements and the number of elements (which is also: do I need to include the bounds or not). 1-based indexing isn't going to help at all in the general case (it will help for the most basic error which is getting the last element of an array with `a[a.length]`, but that's it) |
|