Java OpenJDK Floating Point Dare


Joined
May 31, 2022
Messages
4
Reaction score
0
Is there anyone else out there frustrated with Java OpenJDK floating point errors through float and double and StrictMath? These errors could be repaired by using a symmetrical y=2^n, or openlibm instead of fdlibm. These problems could be solved with, say, 95% compatability intact on the double. If this problem can be mostly solved, I dare anyone capable and willing with Java, C and Assembly to express interest here to give such a go, and to republish the results on Sourceforge!

hpDR3.jpg


Java:
import static java.lang.System.*;
public class Start
{
    public static void main(String ... args)
    {
    out.println("Program has started...");   
    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();   
    out.println(f);
    out.println();
    out.println("Program has Finished.");
    }}

/*
Program has started...

0.010000001

0.010000000000000002

[0.01]

Program has Finished.**
*/
 
Ad

Advertisements

Joined
Sep 21, 2022
Messages
37
Reaction score
4
Floating points were not designed to be exact, they are approximations.

Decimal 0.1 is a recurring fraction in binary, so it gets truncated.

What does y=2^n mean in this context?
 
Joined
May 31, 2022
Messages
4
Reaction score
0
Floating points were not designed to be exact, they are approximations.

That is actually not necessary the case. Around Java 1.1 or so, float and double, maybe StrictMath, in fact were exact. However, they were changed later. What I am looking for is for someone who can create a special version of the OpenJDK that works under similar to or at the original state of affairs.

What does y=2^n mean in this context?

Its just the equation that you use with whole numbers to use numbers that are powers of 2, in series, to add up to any base ten (denary) number that you could need. With base 10 decimal numbers, in between 1 and 0, you can do something similar by considering decimal values as integer values, and then just appropriately bring in and place the decimal point appropriately at the end. This happens in OpenJDK with int and long already, and the whole number parts of float and double already. I raised it because it could be re-applied to repaired decimal values inside float and double as a "mask" for calculating, converting and applying digits in a totally correct manner that will be mostly compatible, if you choose to keep y = 2^n, y = power(2,2) symmetrical around the diagonal line, y=x.
 
Last edited:
Ad

Advertisements

Joined
May 31, 2022
Messages
4
Reaction score
0
Is there anyone out there willing and capable to take on, actively respond to, this OpenJDK matter?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top