Sometimes when programing we have to resolve some simple arithmetic problems, like calculating the remainder elements from a buffer, counting the numbers of elements, etc. In these cases is easy to commit "off by one" mistakes, ie we account one element more or one less. In the better case we are lucky if the program crash in the right place, but we often end up with a bug that is really hard to find.
One trick that I find often useful in these situations is to think that the buffers are much smallers, like zero or one bytes; another option is to think a large and easy number like 1000, etc.
¡¡Confirmado el descubrimiento del primo de Mersenne número 52!!
Hace 4 semanas.
No hay comentarios.:
Publicar un comentario