We will design mealy machine for 2's complement.

Generally we take 2's complement as follows:

- Take 1's complement of the input
- Add 1 to step 1

But here we are taking 2's complement in a different manner to design mealy machine.

The approach goes as follows:

- Start from
**right to left** - Ignore all 0's
- When 1 comes ignore it and then take 1's complement of every digit

**Example**

- Lets take 001 and we know that its 2's complement is (110+1 = 111)
- So scan from right to left
- On state A '1' came first to go to stage B and in output write 1
- On state B replace '0' with '1' and vice-versa
- So finally we got 111 as output
- Be aware that the output is also printed in
**right to left order**