Just don't use an unsigned integer (in C/C++ at least) and then put -5 into it. Semi funny story coming.
Back in the good ole DOS days I had a program that had a small bug in it. It caused the screen to go blank from time to time for about five seconds. Worked fine, but caused the blank screen. DOS text screen.
No step-through debuggers those days, and could not find the bug. Months and months of debugging. Five programmers. Program worked fine, perfect results, just this blank screen every once in a while.
Okay, cut to the chase. Was telling the program to print a certain number of spaces, said number contained in a variable which was (you guessed it) an unsigned integer. Did not have value checking on the value going into that variable and a -5 was sometimes being put in.
It takes a DOS screen five seconds to print 4294967290 spaces, which is how an unsigned int interprets -5.
Integers - signed and unsigned
Moderator: General Moderators