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 Code
< ? php function index ( $ i ) { return 1 + ( $ i >> 31 ) - ( - $ i >> 31 ) ; } function check ( $ n ) { $ s = array ( " negative " , " zero " , " positive " ) ; $ val = index ( $ n ) ; echo $ n , " ▁ is ▁ " , $ s [ $ val ] , " STRNEWLINE " ; } check ( 30 ) ; check ( -20 ) ; check ( 0 ) ; ? >