How to apply the two complement in a hex string in C #?

1

I need help to convert a hex string to a hex string by applying a two-byte complement.

Example: 0x00FEB5AB → 0x00014A55

My hex. 00FF17DB →? (represents a negative latitude)

and 00FCFF75 →? (represents a negative length)

Thank you all.

    
asked by anonymous 20.01.2016 / 13:06

1 answer

4

A simple way could be to calculate the # > and add 1 as described in the entry Complement for two of wikipedia.

I say that it is a simple way because it is easy to calculate the complement of 1 , by applying the operation bitwise NOT to the value:

20.01.2016 / 19:01