如何判断一个数是否有符号,这道题目貌似是微软很早的一道面试。
有些人可能会想只需要判断最高位即可,但是你想一下这样可以吗????
其实这个问题非常简单,只需要定义一个宏就可已解决这个问题。下面我们来看一下,具体实施办法。
#include<stdio.h>
#define ISSIGNED(a) (a>=0 && ~a>=0)
void main()
{
unsigned int a = 1;
printf("%d",ISSIGNED(a));
}
注:当时unsigned时为1,否则为0
![微笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/smile.gif)