How can I compute the 2s complement of a binary number in Excel. Which Excel functions do I need?
For example, if I have the binary sequence 11101010
, the 2s complement can be obtained as,
00010101
00010110
An excel implementation of the above is what I need.
Remember that Two's complement was invented as a way to to a subtraction in a computer to represent negative numbers, so this problem can be solved as a simple subtraction, so get the complement and then add one.
=DEC2BIN(255 - BIN2DEC(A1) + 1)
Where A1 is a cell with a binary number as text. If you want to use a bigger number then use the biggest number that can be represented by the number of bits that you want to use, here my example is for 8 bits, so (2^8)-1 = 255
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With