Assume a positive integer x is given and we wish to get the value of the nth bit of the number's two's complement (written here as −x). 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 nth 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 x=(...x2x1x0)2 and assume that the number has k trailing zeros, that is, xk=1 and xk−1=...=x1=x0=0. So it has the appearance
x=(...xk+2xk+110...0)2.
Now to obtain the two's complement, we must first negate each bit,
x=(...xk+2xk+101...1)2
and then add one to obtain
−x=x+1=(...xk+2xk+110...0)2.
Now we see that
the nth bit of -x={xnxnfor n≤k,for n>k
where k the the number of trailing zeros of the number x=(...x2x1x0)2.