This bug is because the result of subtracting signed and unsigned numbers may overflow if it is negative.