<pre class="lang-cpp prettyprint-override"><code>double r = 11.631;
double theta = 21.4;
</code></pre>

<p>In the debugger, these are shown as <code>11.631000000000000</code> and <code>21.399999618530273</code>.</p>

<p>How can I avoid this?</p>

These
accuracy problems
are due to the
internal representation
of floating point numbers and there's not much you can do to avoid it.
By the way, printing these values at run-time often still leads to the correct results, at least using modern C++ compilers. For most operations, this isn't much of an issue.