C语言中的无符号整数

1. 如何判断一个数为无符号整数

#define ISUNSIGN(A) ((A)>=0 && ~(A)>=0)

2. 求无符号整数数值的负值

  unsigned int u = 2247483648U;
#ifdef _MSC_VER
  __int64 i64;
#else
  long long i64;
#endif

  printf("the value of u is: %xh, %ud\n", u, u);
#ifdef _MSC_VER
  i64 = -(__int64)u;
  printf("the value of i64 is: %I64xh, %I64d\n", i64, i64);
#else
  i64 = -(long long)u;
  printf("the value of i64 is: %llxh, %lld\n", i64, i64);
#endif

 

你可能感兴趣的:(C/C++,语言,c)