# Two's complement of hexadecimal

How do I find two's complement for hex F3A1?

First I converted the number to binary 1111 0011 1010 0001 and then I found two's complement 0000 1100 0101 1111 givin' as result 0C5F which differs from the answer in the book: 0A57

What I'm doing wrong?

• You're not doing anything wrong. Your result is correct. May 18, 2012 at 4:40
• That book's result is so off that I would suspect it may be the right answer to some other question (a question answer mixup).
– Kaz
May 18, 2012 at 6:18

## 3 Answers

Flip 1's to 0's and 0's to 1's (i.e. regular complement). Then add 1.

What you're doing wrong is having too much faith in a book.

But, on the bright side, at least it's some kind of technical book that is probably mostly correct.

• i get the same result, maybe the book has a mistake May 18, 2012 at 4:39
• yep, just go into Windows 7, bring up the calculator, switch to Programmer under View, select Hex and Word mode, enter F3A1 and then press ±, result is C5F (doesn't display leading 0). May 18, 2012 at 5:15
• @tcrosley - nonsense, you can do it on sight! :-) May 18, 2012 at 5:18
• If this was comedians.stackexchange.com you I would vote for you as a moderator :) May 18, 2012 at 9:41
• @MikeJ-UK It took me a few minutes to get my own joke, looking at this over 8 years later.
– Kaz
Dec 17, 2020 at 16:54

If you're a bit acquainted with hex you don't need to convert to binary. Just take the base-16 complement of each digit, and add 1 to the result. So:
F - F = 0
F - 3 = C
F - A = 5
F - 1 = E

So you get 0C5E. Add 1 and here's your result: 0C5F.

for a faster approach you can also flip the bits left to very first set bit and find out the 2s complement(instead of finding 1ns and then adding 1 to it)

1111 0011 1010 0001 toggle the bits left to first set bit
0000 1100 0101 1111

i expect you would like this if bit pattern is changed to binary than hex :)