title: How to get a CGFloat from a NSString?
body: <p>In my current app, I have an equation that typically solves to a pretty long amount of decimal numbers, i.e: 0.12345 or .123 . But the way that I need this to work is to only show say 1 or 2 decimal numbers, so that would essentially produce 0.12 or 0.1 based on the values I mentioned. </p>
  
  <p>In order to do this, I have done the following: Taken my CGFloat to a NSString:</p>
  
  <pre><code>CGFloat eX1 = 0.12345
  NSLog(@" eX1 = %f", eX1);  //This of course , prints out 0.12345
  
  NSNumberFormatter *XFormatter = [[NSNumberFormatter alloc] init];
  Xformatter.numberStyle=NSNumberFormatterDecimalStyle;
  Xformatter.maximumFractionDigits=1;
  
  
  NSString *eX1F = [formatter stringFromNumber:@(eX1)]; 
  NSLog (@"eX1F = %@",eX1F);  //This prints out 0.1
  </code></pre>
  
  <p>But my problem is that I need to keep working with this as a CGFloat after it has been formatted, I have tried taken the string back to a number by doing: <code>numberFromString</code> but the problem is that only works with a <code>NSNumber</code>.</p>
  
  <p>What can I do to format my <code>CGFloat</code> and keep working with it as a <code>CGFloat</code> and not a <code>NSString</code> or <code>NSNumber</code>?</p>
  
  <p><strong>Update</strong> I have tried:</p>
  
  <pre><code>float backToFloat = [myNumber floatValue];
  </code></pre>
  
  <p>but the result is number unformatted : <code>0.10000</code> I need those extra 0s out</p>