title: bash and bc math calculation with decimal point
body: <p>I am trying to implement the following calculation within a Bash script using "bc" but the "scale" option is producing an incorrect result with 2 additional zeros at the end, which means that I am having to trim it manually (ugly).</p>
  
  <p>Calculation:</p>
  
  <p>((2592000-239)÷2592000)×100</p>
  
  <p>Expected result: 99,990779321 (But I would like to show only 2 decimal places)</p>
  
  <p>In Bash:</p>
  
  <pre><code>echo "scale=2; ((2592000-239)/2592000)*100" | bc
  
  99.00
  
  echo "scale=3; ((2592000-239)/2592000)*100" | bc
  
  99.900
  
  echo "scale=4; ((2592000-239)/2592000)*100" | bc
  
  99.9900
  
  echo "scale=5; ((2592000-239)/2592000)*100" | bc
  
  99.99000
  
  echo "scale=8; ((2592000-239)/2592000)*100" | bc
  
  echo "scale=8; ((2592000-239)/2592000)*100" | bc
  
  99.99077900
  
  echo "scale=10; ((2592000-239)/2592000)*100" | bc
  
  99.9907793200
  </code></pre>
  
  <p>According to the man page:</p>
  
  <blockquote>
    <p>NUMBERS
           The most basic element in bc is the number.  Numbers are arbitrary precision numbers.  This precision is both in the integer
    part and the fractional part.  All numbers are represented
           internally in decimal and all computation is done in decimal.  (This version truncates results from divide and multiply operations.) 
    There are two attributes of numbers,  the  length
           and the scale.  The length is the total number of significant decimal digits in a number and the scale is the total number of
    decimal digits after the decimal point.  For example:
                   .000001 has a length of 6 and scale of 6.
                   1935.000 has a length of 7 and a scale of 3.</p>
  </blockquote>
  
  <p>Am I understand this correctly?</p>