title: PHP: Calculating percentage tax applied to a product
body: <p>I've got a significant problem in working out the percentage tax applied to a product, due to the rounding.</p>
  
  <p>For example: </p>
  
  <p>If you have a product which is £1.00 including 20% tax the break down would be:</p>
  
  <pre><code>0.83 ex tax
  0.17 tax
  1.00 total
  </code></pre>
  
  <p>However, if you work out the percentage increase:</p>
  
  <pre><code>round( (( ( 1 - 0.83 ) / 0.83 ) * 100), 2);
  </code></pre>
  
  <p>The answer is <code>20.48</code>, because the actual price ex VAT is <code>0.8333333333</code></p>
  
  <p>Therefore if you calculate:</p>
  
  <pre><code>round( (( ( 1 - 0.8333333333 ) /0.8333333333 ) * 100), 2);
  </code></pre>
  
  <p>You get the correct answer of <code>20</code>.</p>
  
  <p>In this case it would obviously work to round the <code>20.48</code> down to <code>20</code>, but thats not a solution because some tax rates are to 2 decimal places so the assumption can't be made that you can just round the tax rate.</p>
  
  <p><strong>Am I missing something or is this impossible without knowing the original tax percentage?</strong></p>