2011年1月3日 星期一

A < 0, B > 0, but B > A is wrong?

A < 0, B > 0, but B > A is wrong?

int main()
{
  int i = 2147483647;
  unsigned int ui = 2147483647;
  if (i + 1 < 0)     
    printf("i + 1 < 0\n");   
  if (ui + 1 > 0)
    printf("ui + 1 > 0\n");
  if (ui + 1 > i + 1)
    printf("ui + 1 > i + 1\n");
  return 0;
}
The output.
C:\SVN\book\C>a.exe
i + 1 < 0
ui + 1 > 0

1 則留言: