Engineer By Design

September30th

No Comments

If you’re given a positive 16-bit hex value and asked to provide the hex representation of its negative value, it is otherwise asking for the 16-bit 2’s complement of the given value.

So, for example if you’re given 1D7A in hex and asked for representing -1D7A simply take its 2’s complement.

  1. Convert to binary: 1D7A = 0001 1101 0111 1010
  2. Flip the 1’s and 0’s: 1110 0010 1000 0101
  3. Add 1: 1110 0010 1000 0101 + 1 = 1110 0010 1000 0110
  4. Convert back to hex: E286

Therefore, the representation of -1D7A in hex is E286.

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

RSS