title: Formatting floats in Objective C
body: <p>I need to format a float (catchy title, he?) to 2 decimal places, but only if those decimal places have values that aren't zero. Example:</p>
  
  <p>I have a NSTextField named 'answer', after I do some math with a couple of floats, I want to assign my 'answerFloat' variable to the 'answer' NSTextField. So far I've got:</p>
  
  <pre><code>[answer setStringValue:[NSString stringWithFormat:@"%.2f", answerFloat]];
  </code></pre>
  
  <p>But that sets something like 45 to 45.00. I want whole numbers to be displayed without the zeroes, and any decimal numbers to be displayed with their respective decimal values.</p>
  
  <p>Do I need to run some kind of check before giving it to stringWithFormat? Or does NSString offer a way to handle this?</p>