Presumably, because you're going over the maximum possible value that can be held by an int on your platform, and the binary number being stored in your int is one that represents a negative number.
Try outputting the value of s on each iteration of the loop, and you'll be able to see where this is happening.