News for hackers. Stuff that matters.
Re:Inventor Claims to Have Solved Floating Point Error Problem by craftyguy on Thursday January 18, 2018 @01:34PM (#16179890)
>Actually it's possible to represent 1/3 perfectly accurately

I'm curious, how?

Re:Inventor Claims to Have Solved Floating Point Error Problem by ars on Thursday January 18, 2018 @01:36PM (#16179921)
> I'm curious, how?

As 1/3 - exactly as it's on your screen. All rational numbers can be represented exactly.

Re:Inventor Claims to Have Solved Floating Point Error Problem by craftyguy on Thursday January 18, 2018 @01:44PM (#16180011)
Hmm, yes, it can be represented in ASCII. But you still have to approximate when storing it in a way that is actually useful for computation using a finite number of bits.
Re:Inventor Claims to Have Solved Floating Point Error Problem by dragonwriter on Thursday January 18, 2018 @02:06PM (#16180246)
Many real programming languages support arbitrary precision decimal and/or rational numbers.

Sure, there are times when space or speed concerns favor inexact representation over correctness, but that's an optimization that ought to be properly evaluated; the fact that lots of languages are designed in a way which makes it the default everyone reaches for contributes to lots of errors.

Re:Inventor Claims to Have Solved Floating Point Error Problem by umanwizard on Thursday January 18, 2018 @01:47PM (#16180044)

    struct rational {
        int numerator;
        int denominator;
    };
Re:Inventor Claims to Have Solved Floating Point Error Problem by mamcx on Thursday January 18, 2018 @09:49PM (#16183781)
And another dumb questions:

Is possible to convert to rationals in calculations?

So if I do:

1/3 + 4 + sum / total it record values properly?

Re:Inventor Claims to Have Solved Floating Point Error Problem by dreamcompiler on Friday January 19, 2018 @12:06AM (#16184251)
Yes. Common Lisp is an example of a language that can represent rationals exactly and do arithmetic on them. You can avoid floating-point precision loss by using this method. But there are drawbacks: 1) The numerator and denominator will often turn into bignums as a calculation progresses, consuming ever-larger amounts of space and time, and 2) This won't help you with any calculation involving irrationals, except to prevent your initial imprecision from growing larger.