DivideI 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.Numerics

Divides two quantum integers.

operation DivideI (xs : Microsoft.Quantum.Arithmetic.LittleEndian, ys : Microsoft.Quantum.Arithmetic.LittleEndian, result : Microsoft.Quantum.Arithmetic.LittleEndian) : Unit is Adj + Ctl

Description

xs will hold the remainder xs - floor(xs/ys) * ys and result will hold floor(xs/ys).

Input

xs : LittleEndian

$n$-bit dividend, will be replaced by the remainder.

ys : LittleEndian

$n$-bit divisor

result : LittleEndian

$n$-bit result, must be in state $\ket{0}$ initially and will be replaced by the result of the integer division.

Output : Unit

Remarks

Uses a standard shift-and-subtract approach to implement the division. The controlled version is specialized such the subtraction does not require additional controls.