# Twos Complement Converter

This is a decimal/binary to two’s complement converter and a two’s complement to decimal converter. It is a system in which the negative numbers are represented by the two’s complement of the absolute value.

For example : -9 converts to 11110111 (to 8 bits), which is -9 in two’s complement.

Complementing it would make it 9, or 00001001 to 8 bits.

If input number is a decimal number(with or without sign) then we covert decimal number into binary number else we first form the one's complement for given binary number and then add 1 to the one’s complement.

Step 1: Begin with the binary value

**10011001**

Step 2: Formed the one's complement as follows:

**01100110**

Step 3: Add 1 to the one's complement

**01100110**(One's complement)

+ 1 (Add 1)

-----------

**01100111**(Two's complement)

lets take the example of decimal (-44) to form 2's complements as follows:

Step 1: Begin with the decimal value -44

The value will be converted into binary as

**00101100**

Step 2: Formed the one's complement as follows:

**11010011**

Step 3: Add 1 to the one's complement

**11010011**(One's complement)

+ 1 (Add 1)

-----------

**11010100**(Two's complement)