title: XSL - rounding/format-number problem
body: <p>I'm trying to get the value of a number to 2 dec places from my xml.</p>
  
  <p>XML:<code>&lt;Quantity&gt;0.0050&lt;/Quantity&gt;</code></p>
  
  <p>XSL:<code>&lt;xsl:value-of select="format-number($quantity, '####0.00')" /&gt;</code></p>
  
  <p>However XSL seems to have a problem with this value and outputs <code>0.00</code> in one area of the page and <code>0.01</code> in the other. Of course in this situation it is favourable to have <code>0.01</code>  output in all areas.</p>
  
  <p>Another area has the value <code>4.221</code> yet the XSL is outputting <code>4.23</code>.</p>
  
  <p>I do realise that <code>format-number</code> as a method converts a number to a string.  </p>
  
  <p>Not sure how to fix this.</p>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Ok after a bit of mucking around i found that this works:</p>
  
  <pre><code>&lt;xsl:value-of select='format-number( round(100*$quantity) div 100 ,"##0.00" )' /&gt;
  </code></pre>
  
  <p>Via this <a href="http://www.oxygenxml.com/archives/xsl-list/200601/msg00664.html" rel="noreferrer">website</a></p>
  
  <p>As this guy mentions XSL uses 'bankers rounding' to round to even numbers instead of the bigger ones.</p>
  
  <p>The solution hardly seems elegant, and means adding a ton of extra functions to an already bulky and complicated XSL file. Surely i'm missing something?</p>