def le_power_of_2(num):
    """ Gets a power of two less than or equal to num. Works for up to 64-bit
	numbers.
	"""
    num |= num >> 1
    num |= num >> 2
    num |= num >> 4
    num |= num >> 8
    num |= num >> 16
    num |= num >> 32
    return num - (num >> 1)
