All,
I am attempting to convert both positive (127) and negative numbers (like -128) from Decimal (signed integer 8-bit) to Binary to Hexadecimal (1 byte). When it comes to positive numbers, that's pretty simple. However, when dealing with negative numbers, I am unsure how to implement the "Two's Complement" in Excel.
Here's what I have so far
Input Cell (K2)
Output Cell (L2)
Cell N2=IF(K2<0,MID(K2,2,3),K2)
Cell O2=DEC2BIN(N2)
Cell Q2=BIN2HEX(O2,2)
So if I input 127, Cell O2 reads 1111111. When I input -128, Cell O2 read 10000000. When using the "Two's Complement" rule, I would reverse 10000000 then add 1, it should then read 110000000.
However, I have no idea how to reverse the binary and add a binary 1 to the result. My initial thought would be to parse out the binary, manually reverse the numbers (=IF(X2>0,0,IF(X2<1,1)). If that's the way I have to do this reversal, there still lies the question of how to add a binary 1 to the results.
As always, thank you for reading and any input is appreciated!
Respectfully,
Talamon
Bookmarks