L O G I C
Number Complement For Positive Integer For a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Solution To solve above problem we need to generate the binary representation of a number and go through the bits to find the complement of the bit. To get the complement a simple logic can we do the XOR the bit with 1 which will give its complement i.e. 1 ^ 1 = 0 0 ^ 1 = 1 Sample Code
Comments
Post a Comment