News for hackers. Stuff that matters.
Re:I open sourced my game along with a tutorial on how to ma... by wruza on Tuesday July 07, 2020 @08:43AM (#23758592)
Off by ones happen with 0-based too (to me at least, at "write the new codez" stage). What languages are really missing is some stdlib for hiding these calculations under easily understandable names like nthfromend, nfromto, revidx, last, etc. Too much of n-1, n-i-1, -i-1, b-a+1, <, <= to maintain in correct ranges either way.

0/1-based are simply two degenerate around-off-by-one cases of working at general n-based offset, since both 0 and 1 are the most common results of off-by-one.

There are no comments on this comment yet.