Use bitwise 'and' : Bit AND « Data Type « C / ANSI-C






Use bitwise 'and'

#include <stdio.h>

int main(void)
{
  short i;

  printf("Enter a number: ");
  scanf("%hd", &i);

  if(i & 32768) 
      printf("Number is negative.\n");

  return 0;
}


           
       








Related examples in the same category