Integers - signed and unsigned

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post by Bill H »

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.
Post Reply