Hi Naveed,
When dealing with 2's complement, you will have to do your conversions in software. The hardware will be able to read the digital signals on the line but will return these digital values to software as an unsigned binary number. Therefore 1000 on the first four digital lines will be returned to software and read in your API as 8.
Unsigned binary -> 2's complement:
Loop through the number of bits you have (32 for example) and bitwise "xor" each bit starting with the least significant. However, the bits will remain unchanged until the least significant 1 in the number which also remains 1. For example:
1010100 -> 0101100.
2's complement -> Unsigned binary
You can take the reverse of the above.
Another way...
Just take 2^bits+1 - 2's
complement to get the number and 2^bits+1 - number to get the 2's complement. This method requires a double precision floating point number though.
Anyway, hope that helps.
Ron