So, which one is not working the way you expected? Both of these are inherently flawed, since neither variable can ever go negative. In the first case, the unsigned short gets promoted to an int for the comparison, so it will always be greater than -1 (since 0x0 wraps back around to 0xffff, which is 2^16-1 rather than -1). In the second case, it looks like the -1 is getting promoted to an unsigned int which will end up being 2^32-1 (since a -1 is 0xffffffff), which is definitely greater than 3. Basically, if you want to compare to -1, you need to use signed index variables. Cheers, Lyle -----Original Message----- From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On Behalf Of Riyash M H Sent: Wednesday, February 25, 2004 12:13 AM To: gnu@xxxxxxx Cc: gcc-help@xxxxxxxxxxx Subject: Qwery regarding the While() in gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5) Hai pal, I am using gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5). I have got a code which is not working according to what i expect. Can u tell me the reason behind that or is that a bug in the gcc version, i dont have another complier, i executed it with its "g++ " clone also. That too gave me the same results, ----------------------------------------- int main(){ unsigned short i = 3; while(i > -1) printf("%u\n",i--); return 0; } output: 3,2,1,0,65535,............... ------------------------------------------- int main(){ unsigned int i = 3; while(i > -1) printf("%u\n",i--); return 0; } output: "Nothing" -------------------------------------------- One using integer, the compiler is not producing even the assembly code for the while part. The only difference is that in the first the 'i' is 'short' and in the second it is 'int'. please take a look to help me........ thanks.. ===== Riyashmon H Software Engineer, Qcomp Systems & Softwares #2 1st Floor, Vivek Complex, SM Road, Jalahalli West, Bangalore - 560015 Ph: 28399948 Email: riyash@xxxxxxxx ________________________________________________________________________ Yahoo! India Insurance Special: Be informed on the best policies, services, tools and more. Go to: http://in.insurance.yahoo.com/licspecial/index.html