def ones_complement(x, bitsize=16):
    """
    Swap all 1s and 0s.

    01 -> 10
    >>> ones_complement(1, bitsize=2)
    2

    >>> ones_complement(7, bitsize=3)
    0

    >>> ones_complement((ones_complement(15232)))
    15232
    """
    return ((1 << bitsize) - 1) ^ x