Re: OT: Friends forever

Página Principal
Anexos:
Mensagem como email
+ (text/plain)
Apagar esta mensagem
Responder a esta mensagem
Autor: Alan Dayley
Data:  
Para: Main PLUG discussion list
Assunto: Re: OT: Friends forever
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


---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss