Check if binary representation of a given number and its complement are anagram | An efficient Java 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
class GFG { static byte longSize = 8 ; static int ULL_SIZE = 8 * longSize ; static boolean bit_anagram_check ( long a ) { return ( Integer . bitCount ( ( int ) a ) == ( ULL_SIZE >> 1 ) ) ; } public static void main ( String [ ] args ) { long a = 4294967295L ; System . out . println ( bit_anagram_check ( a ) ) ; } }