fencepost error
fencepost error
(1)For example, suppose you have a long list or array of items,and want to process items m through n; how many items arethere? The obvious answer is n - m, but that is off by one;the right answer is n - m + 1. The "obvious" formula exhibitsa fencepost error.
See also zeroth and note that not all off-by-one errorsare fencepost errors. The game of Musical Chairs involves acatastrophic off-by-one error where N people try to sit in N -1 chairs, but it's not a fencepost error. Fencepost errorscome from counting things rather than the spaces between them,or vice versa, or by neglecting to consider whether one shouldcount one or both ends of a row.