is this a valid formula?

and is this calculation correct?

decimal 15

hex value "F"

((10h+F)-1h)+1h

1F

Printable View

- 09-13-2005xddxogm3hex 16's compliment
is this a valid formula?

and is this calculation correct?

decimal 15

hex value "F"

((10h+F)-1h)+1h

1F - 09-13-2005Thantos
I have never even heard of a "hex 16's compliment"

I have heard about 1's and 2's compliment

What are you trying to do? - 09-13-2005BobMcGee123
I thought to convert to hex 16's complement you still just reverse the bits and add 1, but to reverse the bits you just subtract the number from 15.

- 09-13-2005Thantos
Ok so he's just trying to do two's complement without converting first.

yeah it'd (for numbers between 0 and 15):

(F-x)+1

Quote:

((10h+F)-1h)+1h

1F

- 09-13-2005BobMcGee123
Sounds correct to me thantos.

- 09-13-2005xddxogm3
here is the exact question.

Quote:

Will taking the two's complement of a binary number and then converting to hex result in the same hex number as converting the original number to hex and taking its 16's complement?

- 09-13-2005BobMcGee123
I think you need to work that out for yourself, you should have enough knowledge to work some examples out on paper (or, perform a thought experiment).

If you want to have us check your work I think that will be acceptable but is against policy on the boards to just give an answer directly (sorry).

step1:

take the binary number 15:

0000 1111

flip its bits, add 1, then convert it to hex

step2:

take the binary number 15:

0000 1111

convert it to hex

once you have the hex,*subtract it from 15*, add 1, then compare the results to step1.

show us each step. - 09-13-2005xddxogm3Quote:

against policy on the boards to just give an answer directly (sorry).

I'm not trying to get a free answer. I need more direction for my research.

I was asking a question, and thantos requested the exact details that initiated my post.

Anyway, the reason for the post was to clarify the 16's compliment.

That is why my original post asked for insight on how to correct my understanding of the convertion algarithm.

Thantos, thank you for your constructive comments.

one more request for clarification.

Please anyone with constructive comments tell me if i'm off on this.

Code:`n = total bits used`

B = radix/base

([(B^n)] - OriginalValue) = B^nCompliment

10101100b = 172d

01010011b = 83d// Flipped

+1b// Add 1

-------------

01010100b = 84d // 2's Compliment

10101100b = 172d = ACh

11111111b = 255d = FFh

(FFh - ACh) + 1h = 54h = 84d = 01010100b

- 09-13-2005Dave_Sinkula
- 09-14-2005xddxogm3
Dave,

Thanks for the info.

I figured out what i was doing wrong.

I have it perfect now.

That site helped.

I wasn't sure of what subjects to search for.

So it helped.