OT: Friends forever
Alan Dayley
alandd at consultpros.com
Wed Nov 1 18:08:36 MST 2006
Fun!
On Wed, November 1, 2006 5:52 pm, Patrick C wrote:
> or alternatively:
>
> *Code:*
> public void existence()
> {
> boolean friends;
> for(ever = 0; ever <3; ever--)
> {
> friends = true;
> }
> }
- Why "<3" when it could have been "<1" or "<100000"? Does the 3 matter
to the philisophical point?
- "ever" is not declared
- "ever" will be subtracted every time through the look, becoming more
negative each time. Eventually, whatever type "ever" is, it will negative
overflow (ie. roll over) becoming positive. Depending on the system and
compiler, the roll over will produce a zero, thus maintaining the loop or
it will produce a very large positive number, thus ending the loop and
ending existence!
Fixed:
*Code:*
public void existence()
{
boolean friends;
int ever;
for(ever = 0; ever <3; )
{
friends = true;
}
}
;^)
Alan
More information about the PLUG-discuss
mailing list