I made the search on here and on google and couldn't find anything that answered the topic title.
From my bit of understanding, two's complement can be used to make a decimal number, negative.
Which is to say, computing the two's complement of 5 decimal would result in -5 decimal and can be represented as -101 binary, 111111011 binary, or 507 decimal.
Would the two's complement of -5 decimal just result in either of these representations? (-111111011 binary, -507 decimal, or 101 binary)
Edit: I started out trying bitwise not operations and decided to write a function for two's complement also. I'm uncertain of the results for larger numbers.
Example:
twosComplement(-5898238923873); == {
decimal: "589821056097"
negativeBinary: "-111110111011010101011111011001110101110011111"
negativeDecimal: "-34594551032735"
twosCompliment: "1000100101010100000100110001010001100001"
}
00000101would it be required or helpful, for other techniques which might use the result, to keep the zero padding? – ŽaMan Nov 08 '15 at 17:14