Check if a number is positive , negative or zero using bit operators | function to return 1 if it is zero returns 0 if it is negative returns 2 if it is positive ; string array to store all kinds of number ; function call to check the sign of number ; driver program to test the above function
function index ( i ) { return 1 + ( i >> 31 ) - ( - i >> 31 ) ; } function check ( n ) { let s = [ " " , " " , " " ] ; let val = index ( n ) ; document . write ( n + " " + s [ val ] + " " ) ; } check ( 30 ) ; check ( - 20 ) ; check ( 0 ) ;