Check if binary representation of a given number and its complement are anagram | An efficient javascript program to check if binary representations of a number and it 's complement are anagram. ; Returns true if binary representations of a and b are anagram . ; _popcnt64 ( a ) gives number of 1 's present  in binary representation of a. If number  of 1s is half of total bits, return true. ; Driver code
var longSize = 8 ; var ULL_SIZE = 8 * longSize ; function bit_anagram_check ( a ) { var ans = a . toString ( 2 ) . split ( ' ' ) . join ( ' ' ) . length == ( ULL_SIZE >> 1 ) ? 1 : 0 ; return ans ; } var a = 4294967295 ; document . write ( bit_anagram_check ( a ) ) ;