Two's complement

Procedure

The following is the procedure for obtaining the two's complement representation of a given negative number in binary digits:


Procedure

• Step 1: starting with the absolute binary representation of the number, with the leading bit being a sign bit; • Step 2: inverting (or flipping) all bits – changing every 0 to 1, and every 1 to 0; • Step 3: adding 1 to the entire inverted number, ignoring any overflow. Accounting for overflow will produce the wrong value for the result.


Procedure

For example, to calculate the decimal number −6 in binary from the number 6:

WikTok | Your Personalised Encyclopedia

Train your feed. Demystify any topic with AI. Read with friends.

Follow what fascinates you, crack open any topic with AI, save favourites, share great finds, and level up as you go.

Swipe left and right to improve your feed!