Dear Netbeans,

The Oracle article about this is at https://openjdk.java.net/jeps/306.
What it actually refers to is the floating point arithmetic behaviour in Java 
1.1.
It also refers to SSE.  They indeed do refer to the original floating support 
semantics
that were there in version 1.1 of Java.

What they are describing, in these terms, is floating point arithmetic without
error phenomenon.  A circumstance where:

package Java1;

import static java.lang.System.*;

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

     out.println();

     float a = 0.1F;

     float b = 0.1F;

     float c = a*b;

     out.println(c);

     double d = 0.1D;

     double e = 0.1D;

     double f = d*e;

     out.println(f);

     out.println();

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

prints the solution 0.01 in both instances, instead of

0.010000001
0.010000000000000002

I am on Windows 10 64 bit Home, and am using Netbeans 12.5 successfully, but on
top of Java OpenJDK 17.

-First of all, this doesn't seem to require any modules statements.  Why is 
that?

-Most importantly, JEP 306 refers to the adjustment of these very floating
point calculations, such that this code example will output

0.01
0.01

and nothing further, according to the language used.  How can I get
the latter defaulting floating point defaulting behaviour with
OpenJDK 17?

________________________________
From: Rob Walker <r...@ascert.com>
Sent: Wednesday, 17 November 2021 8:31 PM
To: Pieter van den Hombergh <pieter.van.den.hombe...@gmail.com>; A Z 
<powerus...@live.com.au>
Cc: users@netbeans.apache.org <users@netbeans.apache.org>
Subject: RE: Netbeans 12.5 and OpenJDK 17, still with floating point errors?


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