qrisp.q_modf#

q_modf(a: QuantumFloat) Tuple[QuantumFloat, QuantumFloat][source]#

Computes out-of-place the integer and fractional parts of a QuantumFloat.

Parameters:
aQuantumFloat
Returns:
Tuple[QuantumFloat, QuantumFloat]

A pair (i, f) where:

Both are new QuantumFloats with the same configuration as a.

Examples

>>> from qrisp import *
>>> a = QuantumFloat(4, -2)
>>> a[:] = {0.25: 0.25**0.5, 1.75: 0.75**0.5}
>>> i, f = qmodf(a)
>>> i.get_measurement()
{1.0: 0.75, 0.0: 0.25}
>>> f.get_measurement()
{0.75: 0.75, 0.25: 0.25}