How to make the normal operations reversible? There is a gate called Toffoli gate which helps us with that. How? Consider the NAND operation: A NAND B is (https://en.wikipedia.org/wiki/NAND_gate).

The problem with the normal NAND is it does not preserve the A and B values. To be able to solve that problem, we should consider three qubits a,b,c. These three Qubits go into a Toffoli gate and it flips the third gate if the first two are 1. So if we set c to 1, and a and b are 1 as well, then the output of that gate is the NAND of a and b.

So with that we made sure to not, in theory, spend zero energy to do our calculations. To make sure that it happens, you just need to reverse all the computations that you did on the qubits after the result is retrieved.(Not my theory Bennet said that)