title: How to round a floating point number upto 3 digits after decimal point in bash
body: <p>I am a new <code>bash</code> learner. I want to print the result of an expression given as input having <code>3 digits</code> after decimal point with rounding if needed.
  I can use the following code, but it does not round. Say if I give <code>5+50*3/20 + (19*2)/7</code> as input for the following code, the given output is <code>17.928</code>. Actual result is <code>17.92857...</code>. So, it is <em>truncating</em> instead of <strong>rounding</strong>. I want to round it, that means the <strong>output should be</strong> <code>17.929</code>. My code:</p>
  
  <pre><code>read a
  echo "scale = 3; $a" | bc -l
  </code></pre>
  
  <p>Equivalent <code>C++</code> code can be(in <code>main</code> function):</p>
  
  <pre><code>float a = 5+50*3.0/20.0 + (19*2.0)/7.0;
  cout&lt;&lt;setprecision(3)&lt;&lt;fixed&lt;&lt;a&lt;&lt;endl;
  </code></pre>