title: Multiplying and dividing CGFloat and loss of precision
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7302384/cgfloat-addition-bug">CGFloat addition bug?</a>  </p>
  </blockquote>
  
  
  
  <p>I have some code where I'm doing a lot of multiplying and dividing of <code>CGFloats</code> in order to figure out the correct dimensions for transformations. I notice sometimes when I'm suppose to get a value of 320, I'll get 320.00000092 instead. Can anyone explain why this is happening and how to correct it? Is it suppose to be doing this? Here is some sample code where it's possible the problem might be happening:</p>
  
  <pre><code>- (void) setMinimumSize
  {
      CGSize superViewSize = self.superview.bounds.size;
      CGSize size = self.frame.size;
  
      CGFloat xScale = superViewSize.width / size.width;
      CGFloat yScale = superViewSize.height / size.height;
  
      CGFloat minimumScale = MIN(xScale, yScale);
      self.minimumSize = CGSizeMake(size.width * minimumScale, size.height * minimumScale);
  }
  
  - (void) scaleToMinimumSize
  {
      self.transform = CGAffineTransformScale(self.transform, self.minimumSize.width / self.frame.size.width, self.minimumSize.height / self.frame.size.height);
  }
  </code></pre>