Carry operation

Warning

This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.

Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.

Namespace: Microsoft.Quantum.Arithmetic

Package: Microsoft.Quantum.Standard

Implements a reversible carry gate. Given a carry-in bit encoded in qubit carryIn and two summand bits encoded in summand1 and summand2, computes the bitwise xor of carryIn, summand1 and summand2 in the qubit summand2 and the carry-out is xored to the qubit carryOut.

operation Carry (carryIn : Qubit, summand1 : Qubit, summand2 : Qubit, carryOut : Qubit) : Unit is Adj + Ctl

Input

carryIn : Qubit

Carry-in qubit.

summand1 : Qubit

First summand qubit.

summand2 : Qubit

Second summand qubit, is replaced with the lower bit of the sum of summand1 and summand2.

carryOut : Qubit

Carry-out qubit, will be xored with the higher bit of the sum.

Output : Unit