title: show 2 digits max after floating point ... only if it is a float number with more than 2 float digits
body: <p>in my app i do some math and the result can be float or int </p>
  
  <p>i want to show the final result with two digit after the decimal point max ... if result is a float number </p>
  
  <p>there are two options  to do this</p>
  
  <pre><code>number_format($final ,2);
  </code></pre>
  
  <p>and </p>
  
  <pre><code>sprintf ("%.2f", $final );
  </code></pre>
  
  <p>but problem is ... if my final result is a int like <code>25</code> i end up with </p>
  
  <pre><code>25.00 
  </code></pre>
  
  <p>or if final result is some thing like <code>12.3</code> it gives me </p>
  
  <pre><code>12.30
  </code></pre>
  
  <p>and i dont want that</p>
  
  <p>is there any way to format a number to show 2 digits after float point ONLY IF it's a float number with more than 2 digits after decimal point  ? or should i do some checking before formatting my number  ?</p>