However, if the comparison used were <= (less than or equal to), the loop would be carried out six times: index takes the values 0, 1, 2, 3, 4, and 5.
In smaller numbers, however, and specific cases where accuracy is paramount, committing an off-by-one error can be disastrous.
Sometimes such an issue will also be repeated and, therefore, worsened, by someone passing on an incorrect calculation, if the following person makes the same kind of mistake again (of course, the error might also be reversed).
A programmer who misunderstands the third parameter to be the number of increments might hope that linspace(0,10,5) would achieve a sequence [0, 2, 4, 6, 8, 10] but instead would get [0, 2.5, 5, 7.5, 10].
A common off-by-one error which results in a security-related bug is caused by misuse of the C standard library strncat routine.
A common misconception with strncat is that the guaranteed null termination will not write beyond the maximum length.
In reality it will write a terminating null character one byte beyond the maximum length specified.
On some systems (little endian architectures in particular) this can result in the overwriting of the least significant byte of the frame pointer.
This can cause an exploitable condition where an attacker can hijack the local variables for the calling routine.
Such functions include strlcat and strlcpy, and are often considered "safer" because they make it easier to avoid accidentally writing past the end of a buffer.