Double vs Float - Java : <p>Well I have following program. It is given by my teacher for fun. I got surprise about the result. </p>

<p><strong>Code:</strong></p>

<pre><code>public class Testing {

    public static void main(String[] args) {

         float     piF =  3.141592653589793f;   // value assigned has float precision
         double    piD =  3.141592653589793;   //  value assigned has double precision
         final double THRESHOLD = .0001; 
         if( piF == piD) 
            System.out.println( "piF and piD are equal" ); 
         else 
            System.out.println( "piF and piD are not equal" ); 
         if( Math.abs( piF - (float) piD ) &lt; THRESHOLD ) 
            System.out.println( "piF and piD are considered equal" ); 
         else 
            System.out.println( "piF and piD are not equal" ); 

    }

}
</code></pre>

<p><strong>Result:</strong></p>

<pre><code>piF and piD are not equal
piF and piD are considered equal
</code></pre>

<p>Well why piF and piD are not equal ? And what actually <code>Math.abs()</code> do that makes both same ?</p>
