title: Unexpected floating point comparisons
body: <p>Consider the following code: </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #define k 0.7
  #define p 0.5
  int main()
  {
      float a=k,b=p;
      double aa=k;
      if(a&lt;k)
      {
           if(b&lt;p) printf("2 is right");    
           else      printf("1 is right");
      }
      else printf("0 is right");
      printf("\n");
      if(a&gt;k)
      {
           if(b&lt;p) printf("2 is right");    
           else      printf("1 is right");
      }
      else printf("0 is right");
      return 0;
  }
  </code></pre>
  
  <p>Consider this as part II of <a href="https://stackoverflow.com/questions/7011184/floating-point-comparison">this</a> question, here the understanding was that the double precision values of floating point constants (doubles when represented as numeric constants) was lost when it was converted to their corresponding floating point values. The exceptional values were X.5 and X.0. But I observed the following results:</p>
  
  <pre><code>Input           Output
  K=0.1 to 0.4        0 is right
                      1 is right
  
  K=0.5               0 is right
                      1 is right
  
  K=0.6               0 is right
                      1 is right
  
  K=0.7               1 is right
                      0 is right
  
  K=0.8               0 is right
                      1 is right
  
  K=0.9               1 is right
                      0 is right
  
  K=8.4               1 is right
                      0 is right
  </code></pre>
  
  <p>Why is this queer behavior? How come only few floating point values are displaying this property? Can't we assume that <code>float</code> precision values are <em>always less</em> than <code>double</code> precision values?? How do we explain this behavior?</p>