Jump to content

two's complement

Featured Replies

I am trying to understand what how to use two's complement.

 

If I have the number 128, I know that I can find the number by converting 128 to binary such as:

 

0000 0000 1000 0000

 

Then invert the digits like so:

 

1111 1111 0111 1111

 

Then add one to it like so:

 

1111 1111 1000 0000

 

which will give me -128

 

but what about if I want to find 2's complement of -128 would I still do it the same way as above which would give me the value of 128?

 

 

I am new at this please help?:confused:

Try it. What does inverting the digits and adding one do to 1111 1111 1000 0000 ?

@ computerbum

 

The two's complement of a negative number is always the corresponding positive value.

 

For example, inverting the bits of −5 (above) gives:

 

00000100

 

And adding one gives the final value:

 

000001012 = 5

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.