Well, the negatives were amusing. I suspect that what happened is the numbers got bigger than could be represented with the number type in the code. when that happens the sign bit gets changed and the number wraps around becoming negative. basically the biggest number + 1 = the most negative number.
