title: Strange problem comparing floats in objective-C
body: <p>At some point in an algorithm I need to compare the float value of a property of a class to a float. So I do this:</p>
  
  <pre><code>if (self.scroller.currentValue &lt;= 0.1) {
  }
  </code></pre>
  
  <p>where currentValue is a float property.</p>
  
  <p>However, when I have equality and <code>self.scroller.currentValue = 0.1</code> the if statement is not fulfilled and the code not executed! I found out that I can fix this by casting 0.1 to float. Like this:</p>
  
  <pre><code>if (self.scroller.currentValue &lt;= (float)0.1) {
  }
  </code></pre>
  
  <p>This works fine.</p>
  
  <p>Can anyone explain to my why this is happening? Is 0.1 defined as a double by default or something?</p>
  
  <p>Thanks.</p>