Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

i am having trouble to understand complement..

Status
Not open for further replies.
i am having trouble to understand the meaning
of complement 1 and complement 2 of a certain number

after looking a this table:**broken link removed**

i came to the conclution that the complement 1 and complement 2 of a positive stays the same
but in the case of a negative number
there is a unique transformation for each type
of complement.

how does the complement to 1 and the complement to 2
changes the value of a negative number

and why it doesnt change possitive numbers
 
Twos compliment subtracts the number from zero and so the top bit gets set. To obtain a twos compliment number you invert all the bits and add 1 to the result. So, 1 (00000001) gets inverted (11111110) and then incremented (11111111) to get -1. Also, -1 (11111111) gets inverted (00000000) and then incremented to get (00000001) 1.

Ones compliment is the same except you don't do the increment after the inversion. So, -1 = 11111110.

In both systems the largest positive number is 127.

Check wikipedia for a longer explanation.

Mike.
 
i was told some thing else..

is it ok???


" Ones complement and twos complement are methods of representing negative numbers. Therefore, they don't affect positive numbers.

To represent a negative number in ones complement, the positive value simply has all its bits inverted. Example: to represent -25 in ones complement, take the binary representation of +25 which is 00011001, then invert the bits: 11100110. Done.

To represent a negative number in twos complement, take the ones complement from the previous example, and add one to it: 11100110 + 00000001 = 11100111
"
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top