comparison between signed and unsigned int
- From: compcreator@xxxxxxxxx
- Date: Fri, 21 Sep 2007 06:16:07 -0700
I have tried the following program. The problem is it is printing
False
I checked values for a and b but there is something wrong with the
comparison.
I thing it might be because of signed and unsigned conversion.
Either b is upgraded to unsigned and the resulting value during
comparison is > 5 or a is downgraded to signed and the resulting value
is lower than -1.
void main()
{
unsigned int a = 5;
signed int b = -1;
if(b <= a)
printf("True");
else
printf("False");
}
Can somebody explain why is this happening....?
.
- Follow-Ups:
- Re: comparison between signed and unsigned int
- From: Army1987
- Re: comparison between signed and unsigned int
- From: CBFalconer
- Re: comparison between signed and unsigned int
- From: Keith Thompson
- Re: comparison between signed and unsigned int
- From: Mark Bluemel
- Re: comparison between signed and unsigned int
- From: Ben Pfaff
- Re: comparison between signed and unsigned int
- From: Tim Prince
- Re: comparison between signed and unsigned int
- Prev by Date: Re: sob..Someone can help me????plsss
- Next by Date: Re: Any search pattern method recommed for mmap memory
- Previous by thread: facing problem during compilation
- Next by thread: Re: comparison between signed and unsigned int
- Index(es):
Relevant Pages
|