The Answer (is perfect for you)
Well, time for some explanation.
if (-1 < 10U) { foo(); } else { bar(); }
Answer: bar() (on most compilers. see below.). Why? According to ISO C++ 1998, section 5.9, binary operators promote operands until they are the same type. unsigned int
is higher up in this heirarchy of types, so it is preferred over signed int
. So -1 is converted to an unsigned int. How is it converted? Well, since -1 is outside of the range of unsigned int, the converted value is implementation defined (4.7.3). Technically, either foo() or bar() could be called. However, in *most* implementations -- that is, two's complement -- the bit pattern doesn't change. So -1 becomes the largest possible unsigned integer (0xFFFFFFFF if sizeof(int) == 4), which is clearly larger than 10.
And this is why most compilers warn you about comparisons between signed and unsigned integers! Heed them!
Here's a question I don't know the answer to: How do you initialize a signed (32-bit) integer to its smallest possible value in a standard way?
int smallest = -0x80000000;
VC7.1 gives a warning here because 0x80000000 doesn't fit in a signed int, so it becomes unsigned. However! You then apply the unary negation operator to an unsigned int, giving something that doesn't fit in the unsigned range! How would you do it on a platform that doesn't use two's complement?
And now for something completely different... (I like to wear women's panties!)
Sucks to XHTML 1.0 Strict-ify those LJ things...
[HTML_REMOVED](I like to wear women's panties!)[HTML_REMOVED]
Brother + women's panties = DISTURBING o_O
Makes Ebichu look like nothing!
It's one of a rare few sentances that can be appended [HTML_REMOVED]anywhere[HTML_REMOVED] to come up with an amusing non-sequitor. "I like to rape hookers!" is another example.
It's an inside joke between me and andy.
I was hoping it was something like that...
AAAHHH I got it wrong 8>(
It's not working... I tried to add myself to the map without logging in first, and it erred. Then I tried logging in to eliminate the error condition, and it tells me "lordgalbalan" is locked. I try to unlock lordgalbalan but no, there will be no lock broken. :?
Maybe... it worked anyway?
Hm... I had a weird problem like that too. But it apparently added me to the map anyway. So maybe you should check?