Precision lost in float value using java
<p>Given below the test code and its output. When I get float value from number value, precision is lost.. Can anyone tell me why this behaviour and also how to handle this? </p>

<pre><code>public static void main(String[] args)
    {
        try
        {
            java.lang.Number numberVal = 676543.21;
            float floatVal = numberVal.floatValue();
            System.out.println("Number value    : " + numberVal);
            System.out.println("float value     : " + floatVal);
            System.out.println("Float.MAX_VALUE : " + Float.MAX_VALUE);
            System.out.println("Is floatVal &gt; Float.MAX_VALUE ? " + ( floatVal &gt; Float.MAX_VALUE));
        }catch(Exception e)
        {
            e.printStackTrace();
        }
    }
</code></pre>

<p>output:</p>

<pre><code>    Number value    : 676543.21
    float value     : 676543.2
    Float.MAX_VALUE : 3.4028235E38
    Is floatVal &gt; Float.MAX_VALUE ? false
</code></pre>

<p>also  why the float value lesser than Float.MAX_VALUE?  </p>
