quantumlib / Qualtran

Qᴜᴀʟᴛʀᴀɴ is a Python library for expressing and analyzing Fault Tolerant Quantum algorithms.
https://qualtran.readthedocs.io/en/latest/
Apache License 2.0
177 stars 44 forks source link

Add `ToFxp` to convert a `QUInt` to a `QFxp` #1180

Closed charlesyuan314 closed 3 months ago

charlesyuan314 commented 3 months ago

This bloq enables us to safely convert between QUInt and QFxp of compatible size and to divide integers by powers of two in the process.

If the bitsize of the output is equal to the input, then Cast could be used as an unsafe alternative. This bloq is a little safer and supports using a larger register to store the divided the value.