65,187
社区成员




return (x >> 30) | (((static_cast<UINT64>(~static_cast<UINT32>(x)) + 1) >> 32) ^ 1);
int SIGN(int x)
{
return ((((x>>31)&1)^1)*x||0)-((x>>31)&1);
}
return (x + 1) / abs( x + 1 ) ;
#include <stdio.h>
int compare(int a);
int main()
{
int a;
while(scanf("%d",&a) == 1)
{
printf("%d\n",compare(a));
}
}
int compare(int a)
{
// 正数:1-0;0:0-0;负数:0-1
int i = 0;
int m = 0;
for(i = 0; i < 31 ; i ++)
{
m = ((a>>i)&1)|m;
}
return m-(a>>31&1)-(a>>31&1);
}
int SIGN(int x)
{
return ( x > 0 ) - ( (x & 0x80000000 ) == 0x80000000 );
}
int SIGN(int x)
{
return ( x > 0 ) - (x < 0);
}