# Converting a qubit's state to a binary value in Q#

In Q#, How do I store a qubits state in a binary-based disk / hard drive for use by regular digital programs? Is this even possible?

• Are you asking for an exact representation not an approximation? – AHusain Jun 4 at 20:17
• Exact representation – AJ_4real Jun 4 at 20:48

## 2 Answers

No, it is not possible. Consider simply counting the number of possibilities. You have N bits so can only differentiate $$2^N$$ possibilities. How many possible states are there for 1 qubit if you don't do any approximation?

If you do some approximation, then you may want to store the circuit that produced the given state starting from $$| 0 \rangle$$. But that would have had gates like rotation by some angle $$\theta$$ in which case storing $$\theta$$ would be using the floating point approximation of real numbers in order to turn it into something representable with finite amount of bits.

Don't make the type error of floats vs reals.

What use case do you have in mind?

Q# allows you to produce human-readable dump of wave function using DumpMachine operation (see this question for more details). However, this does not give you an exact representation, since the floating-point numbers used for storing the amplitudes internally are by definition not exact.