expressing hex value in 2's complement
问题 i have a string hex value, and i need to express it in 2's complement. string hx = "FF00"; what i did is, converting it to binary: string h = Convert.ToString(Convert.ToInt32(hx, 16), 2 ); then inverting it, but i couldn't use the NOT operator. is there any short way to invert the bits and then adding 1 (2's complement operation)? 回答1: The answer might depend on whether or not the bit width of the value is important to you. The short answer is: string hx = "FF00"; uint intVal = Convert