Assume a positive integer is given and we wish to get the value of the th bit of the number's two's complement (written here as ). Now if a fixed number of bits is used to represent the number, say 32 or 64, the two's complement can be computed explicitly and the th bit can be found directly. But if we work with arbitrary precision then any two's complement representation has infinitely many 1s at the left.
Let some positive number have the binary representation and assume that the number has trailing zeros, that is, and . So it has the appearance
Now to obtain the two's complement, we must first negate each bit,
and then add one to obtain
Now we see that
where the the number of trailing zeros of the number .