title: Remove Trailing Zeros After Decimal C++
body: <p>I have been trying to do a very easy thing and it's taking me hours. I can't seem to find a good answer to this question.</p>
  <p>I have various numbers, I need to keep only up until the third digit after the decimal.
  But, if there are trailing zero on the right, remove them.
  For example:</p>
  <pre><code>0.015356 -&gt; 0.015
  0.015000 -&gt; 0.015
  0.010320 -&gt; 0.01
  0.000320 -&gt; 0
  </code></pre>
  <p>I have the numbers as float/double. I need to pass them into another function which will then print them. I don't have control over the other function. I can pass either numbers or strings, and they will get printed accordingly.</p>
  <p>I suppose I need to pass on a string, cause otherwise it can't be achved?</p>
  <p>I was able to remove the digits up until the third:</p>
  <pre><code>num = floor(num*1000)/1000;
  0.015356 -&gt; 0.015000
  0.000320 -&gt; 0.000000
  </code></pre>
  <p>But now I have the problem of the trailing zero.</p>
  <p>In short, how can I achieve what I need?</p>