title: Converting numbers to float with 2 decimal places
body: <pre><code>float f = 0.00f;
  System.out.println(f);      
  </code></pre>
  
  <p>gives the output: </p>
  
  <pre><code>0.00
  </code></pre>
  
  <p>I'd like to format a number represented by a percentage to 2 decimal places. But the result <i><strong>should be a float</strong></i> and <strong>not</strong> a string.</p>
  
  <p>e.g. </p>
  
  <pre><code>10.001 needs to be converted to 10.00
  0.0 needs to be converted to 0.00
  78.8  needs to be converted to 78.80 
  </code></pre>
  
  <p>The values thus formatted will be assigned to a float.. how would one accomplish this?</p>