Saturday, August 25, 2007

C++ note: unsigned int

Suppose a is an unsigned int, the expression a>-1 is always false. This is because the type of -1 is decided by the type of a, and it becomes maxint.

Hint: remember the unsigned int variables in the code and do not compare them with a minus number. The comparison itself is not necessary.

No comments: