title: Formatting numbers using DecimalFormat
body: <p>I am trying to format prices using DecimalFormat, but this isn't working for all variations.</p>
  
  <pre><code>DecimalFormat df = new DecimalFormat("0.##")
  df.format(7.8)
  df.format(85.0)
  </code></pre>
  
  <p>prints</p>
  
  <pre><code>7.80
  </code></pre>
  
  <p>and</p>
  
  <pre><code>85
  </code></pre>
  
  <p>but "7.79999" gets formatted as "7.8", not "7.80". I have tried doing things this way</p>
  
  <pre><code>DecimalFormat df = new DecimalFormat("0.00")
  </code></pre>
  
  <p>to force two dp, but then "85.0" gets formatted as "85.00" not "85"!</p>
  
  <p>Is there a way of capturing all variations, so that prices are printed either as #, ##, or #.##? For example:</p>
  
  <blockquote>
    <p>5, 55, 5.55, 5.50, 500, 500.40</p>
  </blockquote>