 <p>Due to the insight of @OliverCharlesworth I have changed the data to be an unsigned long long. Also as suggested by @Olaf I did the calculations as a float.</p> <pre><code>unsigned long long Parallel::getResistance(Resistor &amp;r1, Resistor &amp;r2) { return 1.0 / (1.0 / r1.getResistance() + 1.0 / r2.getResistance()); } </code></pre>