Re: Incorrect warning
Re: Incorrect warning
- Subject: Re: Incorrect warning
- From: Steve Mills <email@hidden>
- Date: Tue, 16 Nov 2004 10:11:09 -0600
On Nov 16, 2004, at 09:49, Bryan Pietrzak wrote:
You're joking right?
UInt32 a = 0xFFFFFFFF;
SInt32 b = -1;
Aren't these two values very different even though they have the same
bit representation?
Well, we've been using -1 and 0xffffffff as the same thing for so long,
that my first answer would be "they're the same".
What's interesting is this bit of code completely fails my
expectations:
UInt32 a = 0xFFFFFFFF;
SInt32 b = -1;
if (a == b)
{
SysBeep(1);
}
In both XCode and CodeWarrior the SysBeep is executed. In this
situation, even though a and b are bitwise equal, they do not
represent the same value and I would not have expected the equality
test to succeed.
To do the actual comparison, you'd need to turn -1 into an unsigned
value (which happens to be 0xffffffff) or turn 0xffffffff into a signed
value, which would mean moving it into a 64-bit value.
It's too bad there wasn't something established in the standard for a
4-char data type instead of them actually being signed or unsigned
longs. Then this whole conversation would not have happened because
Xcode wouldn't be complaining about a simple comparison (well,
CodeWarrior too, but we've always left that warning off). They're so
damned useful and much easier to recognize than something like
0x3a27f76e.
Steve Mills
Drummer, Mac geek
http://sjmills5.home.mchsi.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden