|
|
|
|
|
by IshKebab
473 days ago
|
|
Off-by-one errors are more likely with 1-based indexing because they don't have the nice properties of 0-based/right open intervals that mean you don't have to add or subtract 1 all over the place. For example what is the index of pixel X,Y in an image buffer? X + Ystride right? Nope! It's X + (Y-1)stride. What's the range of the Ith block of N elements? [in, in + n)? Nope! It's [(i-1)n+1, in]. I have to deal with that nonsense in Matlab all the time. Nightmare. |
|