Mail Archives: djgpp/1998/07/09/15:20:58
From: | dns AT cyberdude DOT com
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Infinite loop???
|
Date: | Wed, 08 Jul 1998 22:38:27 +0200
|
Organization: | MatavNet
|
Lines: | 17
|
Message-ID: | <35A3D8C3.208E6D23@cyberdude.com>
|
NNTP-Posting-Host: | line-210-94.dial.matav.net
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
I use the following code:
unsigned short s=1;
unsigned int t=1;
while ((s<<t)!=0) { // this loop is infinite! but why?
t++; }
In RHIDE I tried to step trough the code but even when the expression
seems to be false it stays in the loop.
changing the loop to:
while ((unsigned short)(s<<t)!=0) {
t++; } // this gives good answer
but then the above wont work on data types int/long only if I change !=0
to != 1
I don't understand why its working like this. I used BC before and it
gave me correct answers.
Any help would be appreciated.
Thanks,
Dns
- Raw text -