I'm trying to understand what a two byte hexadecimal value would look like. As an example, we have the decimal values 41 and -73 with their two-byte binary equivalents:
dec
41 -binary: 000000 00101001
-73 -binary: 11111111 10110111
The hex should then be 29(base16) and 49(base16) respectively. How are these hex values represented in a "two byte" value. Am I doing something wrong here?
thanks
11111111 10110111in binary. 41 in hex would be0x0029and -73 would be0xFFB7.0x0049would be +73.15-numberto get complements? If you subtract 15 from every value it should be0xFFB6?16-number. Personally I find the easiest way to perform 2's complement is by flipping all the bits and adding one. That way a +730000 0000 0100 1001would become a -73 like so:1111 1111 1011 0110+1. You can then see, looking at the groups of 4 bits, we getF F B 7.