# How to apply a gate to a LittleEndian in Q#

I have been given a LittleEndian register. I want to know the following things:

1. How many bits there are in the LittleEndian?
2. How to convert the LittleEndian into a Qubit[] Array.
3. How to access individual qubits of LittleEndian?
4. How to apply simple and controlled gates onto individual qubits of LittleEndian?

The LittleEndian type is basically a wrapper for a register of qubits to let the user know how to interpret it as another value. It changes nothing about the register it wraps.

1. There is no fixed number of bits in a LittleEndian, it only documents that the least significant bit of a register is index 0 (on the left).
2. If you want to get back just the register not wrapped in the LittleEndian type, you can use the ! operator like this:
using (register = LittleEndian(Qubit[3]) {
ResetAll(register!);
}

1. Similar to #2 if you us ! to unwrap the LittleEndian type you can then index it like normal.
2. Same as #3, just unwrap the type and you should be able to do the gates as you would regularly. The controlled functor may be of use to you.

I also have a section in my book that talks about how to use UDTs or User Defined Types which LittleEndian is an example of (provided by the Numerics library)

• Thank you for "!" reminder. Not sure about using() with LittleEndian type inside. Jun 15, 2020 at 14:07