Write a python function to find One's compliment of a number


Topic: Write a python function to find One's compliment of a number

Solution

import math
def OnesComplement(num):
    bits = int(math.floor(math.log(num) / math.log(2)) + 1)
    return ((1 << bits) - 1) ^ num



List all Python Programs