Check if two numbers are bit rotations of each other or not | function to check if two numbers are equal after bit rotation ; x64 has concatenation of x with itself . ; comapring only last 32 bits ; right shift by 1 unit ; Driver Code
< ? php function isRotation ( $ x , $ y ) { $ x64 = $ x | ( $ x << 32 ) ; while ( $ x64 >= $ y ) { if ( ( $ x64 ) == $ y ) return 1 ; $ x64 >>= 1 ; } return -1 ; } $ x = 122 ; $ y = 2147483678 ; if ( isRotation ( $ x , $ y ) ) echo " yes " , " STRNEWLINE " ; else echo " no " , " STRNEWLINE " ; ? >