# Toggle between Half-adder and Half-subtractor

I have constructed a half-adder that looks like this:

And a half-subtractor like this:

It's basically the same circuit except the AND gate at the bottom has a NOT before it for one of the inputs. I would like to combine the two so that I can perform (half-) addition or subtraction based upon a third boolean input. Zero would mean Add and One would mean Subtraction. What would be an example of how I could 'route' the input into an optional NOT gate based upon the type of operation being performed?

One idea I had was to put the operation input into an XOR gate before the AND input.

• @jsotola I already did, and it worked. I'm seeing what other solutions there might be. – David542 Mar 26 at 0:59
• @jsotola agreed, thanks for the feedback. – David542 Mar 26 at 5:00