Suppose the number to test is stored in the 32-bit signed int variable n. You can start by using ! to check for zero:

if (!n)

return 0;

The C language treats the number zero as false and any nonzero value as true, so (!n) evaluates to true if and only if n is zero.

Next, you can check for negative n using bitwise &.

if (n & INT_MIN)

return -1;

In binary, the lowest representable value of a signed int is represented by a string of zeroes with just the sign bit set. For instance, binary 1000....0 (31 zeroes) is the 32-bit signed int representation of -2147483648. The C library file limits.h stores this number as INT_MIN. By doing (n & INT_MIN), the result is either going to be 0 (if the sign bit of n is not set) or INT_MIN (if the sign bit of n is set), which as already mentioned evaluates to false and true, respectively, in the if-statement. You could even just hard code -2147483648 in place of INT_MIN if you don't want to include limits.h.

Lastly, if neither if-statement is true, you can conclude that n is positive (and return 1).