How to treat a double 3.14567 as a 3.14 (i.e with a given percision)
<p>I was wondering if there is any way in c++ to treat a double with a given precision.
for example, the number 3.1345 will be considered as 3.13 and the number 0.009 will be considered as 0 (precision of 2 after the dot).</p>

<p>I need that it will be applied on mathematical operations. for example:</p>

<pre><code>double a = 0.009;
double b = 3.12345

//a should be considered as 0, b as 3.12

double c = a*b // should output 0.
double d = a+b // should output 3.12
</code></pre>

<p>since the function setprecision() is for std i was wondering if there is any other function to do that.</p>

<p>thanks </p>
