title: How does printf or iostream specify maximum number of digits after the point
body: <p>What format string in <code>printf</code> or <code>iomanip</code> operator in iostream should I use to print the float in the following format:</p>
  
  <ul>
  <li>125.0 => 125</li>
  <li>125.1 => 125.1</li>
  <li>125.12312 => 125.12</li>
  <li>1.12345 => 1.12</li>
  <li>1234.1235 => 1234.12</li>
  </ul>
  
  <p>In short, print at most 2 digits after the point, but remove all trailing zeros.</p>
  
  <p>I tried <code>%.2f</code> but doesn't work because it prints 125.00 and 125.10 for the first 2 cases.</p>