Thursday 10 October 2024

Binary Complement

I hadn't really heard of the binary complement or 1's complement as it's alternatively called until I came across one of the sequences of which 27583 is a member. The sequence is OEIS A323067:


A323067    Primes whose binary complement (A035327) is a square.

To find the binary complement of a number, simply the invert the 0's and 1's in its binary representation. Let's use 27583 and its binary representation as an example:$$27583_{10}=110101110111111_2$$It's binary complement is:$$1010001000000_2=1584_{10}=72^2$$Thus 27583 does belong in OEIS A323067 and Table 1 shows the members of the sequence up to 40,000 together with their binary complements and square roots:


Table 1: permalink

Notice that powers of 2 plus 1 will all have binary complements equal to 0. All decimal numbers have a 1's complement or binary complement. However, it is not 1-to-1 relationship as different numbers can have the same complement. This is different to the Gray Code that also involves manipulation of the binary digits of a number to produce a new number but involves a 1-to-1 relationship.

The following source gives more information about the topic and its applications:  https://www.tutorialspoint.com/one-s-complement

No comments:

Post a Comment