Love your answer Pieter – I can almost hear the words of my late father (who 
was a scientist and a computer geek)

“… if you want absolute accuracy, you need integers and fractions … if you can 
live with an approximation, then floating point is probably good enough …”

-R


From: Pieter van den Hombergh <pieter.van.den.hombe...@gmail.com>
Sent: 17 November 2021 09:19
To: A Z <powerus...@live.com.au>
Cc: users@netbeans.apache.org
Subject: Re: Netbeans 12.5 and OpenJDK 17, still with floating point errors?

You may be misled by the name strictfp.

strictfp means that the results are independent of the platform and or 
implementation, so that the results will be the same always.
This was an aspect because of the fact that intel FP processors use 80 bits 
internal, which can produce different results in some cases, because the 
results are rounded to 64 bit (float) in Java, with results different
for intel and other platforms. The purpose of strictfp is to make the results 
consistent, not more 'accurate'.

The computations you do are inherently/ fundamentally problematic with binary 
floating point, because 0.1 decimal is a repeating fraction in binary, much 
like 1/3 is in decimal.




On Wed, Nov 17, 2021 at 10:02 AM A Z 
<powerus...@live.com.au<mailto:powerus...@live.com.au>> wrote:
If I try to compile the following, I get a warning that strictfp
won't be needed:

package Java1;

import static java.lang.System.*;

public strictfp class Start
{
    public static void main(String[] args)
    {
     out.println("Greetings");

     out.println();

     out.println(0.1f*0.1f);

     out.println(0.1d*0.1d);

     out.println();

     out.println("Goodbye.");
    }
}

Yet if I take the strictfp out, and compile again, I have no warning, yet when 
I run this,
it still possesses the former floating point errors.  Didn't JEP 306 on the 
Oracle site
officially say that floating point errors at default were going to be removed?

Can someone specifically reply to me explaining what is going on here,
and if there is a way for floating point arithmetic in Java to default to JEP 
306
accuracy mode?


--
Pieter Van den Hombergh.
No software documentation is complete with out it's source code.

Reply via email to