C Bit Twiddling
int value=-25;
    int sign = 0;
 
    //First Method
    sign = -(value < 0);
 
    //Second method 
    sign = 1 | value >> (sizeof(int)*8 - 1);
 
    //Third Method
    sign = (value>0) - (value<0);
    printf("%d",sign);

The statement sizeof(int) returns the value 4 which means that the integer variable requires 4 bytes of storage.
The operation 1 | -1 gives us the value of -1

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License