index of hydrogen deficiency
You seem to be using a very simplified version of the index of hydrogen deficiency. A more complete expression is:

$$IHD = \frac{2C + 2 - H - X + N}{2}$$

Where $C$, $H$, $X$, and $N$ represent the number of carbon, hydrogen, halogen, and nitrogen atoms, respectively. The logic of the IHD is that any simple acyclic alkane has a formula of $\ce{C_{n}H_{2n + 2}}$, meaning that given $n$ carbons, a simple acyclic alkane will have $2n + 2$ hydrogens. Every increment in the IHD represents either a degree of unsaturation due to $\pi$-bonds, or the presence of a ring. In your formula, $H_{reference}$ should be twice the number of carbons in your molecule, plus two. $H_{molecule}$, on the other hand, is the actual number of hydrogens in the molecule.

For example, if your molecule has the formula $\ce{C6H8}$, $H_{reference} = 2(6) + 2 = 14$ and $H_{molecule} = 8$. The IHD is then $\frac{14 - 8}{2} = 3$, suggesting that the total number of $\pi$-bonds plus rings in the molecule is three. Note that this isn't sufficient to determine the actual structure of the molecule, but it's helpful when combined with spectroscopy data (that is, it could have one ring and two $\pi$-bonds, or just three $\pi$-bonds, or some other combination).