in reply to Re: Perl 5 numeric type and simplifications (updated)
in thread Perl 5 numeric type and simplifications

... even if it's internal representation is flawed

It would be better to instead say "even if it's internal representation is rounded." Rounding is not a flaw - unless, of course, the rounding was done in an incorrect manner.

... part of arithmetic operations which accumulated rounding errors

Similarly, I would rewrite that as (something like) "part of arithmetic operations which were rounded".

Just to be clear - both "flawed" internal representations and "rounding errors" are very rare in perl. I think both of those phrases should be reserved to apply to cases where rounding has been done incorrectly.
If those errors are encountered in perl-5.30.0 or later then I'd recommend reporting them.

On USE_QUADMATH builds of perl, some sqrt() operations round incorrectly (by one unit of least precision). And, with USE_LONGDOUBLE builds of perl on Windows there's a specific range of values that don't assign correctly.
There's also some BSD and Solaris (and perhaps other) systems around that have some pretty weird rules regarding USE_LONGDOUBLE arithmetic. (I think that they are "flawed", though it might be arguable.)
Offhand, I struggle to recall there being any flawed internal representations or rounding errors on perl-5.30 or later when perl's NV is "double".

Cheers,
Rob
  • Comment on Re^2: Perl 5 numeric type and simplifications

Replies are listed 'Best First'.
Re^3: Perl 5 numeric type and simplifications
by LanX (Saint) on May 07, 2021 at 10:07 UTC
    Did I say it's a Perl problem?

    I learned the terms "rounding error" and "accumulated rounding error" in CS classes at university for these effects. °

    To be sure it's not a translation problem, I searched and found (among many others) this English Wikipedia article

    > Rounding error

    A roundoff error, also called rounding error, is the difference between the result produced by a given algorithm using exact arithmetic and the result produced by the same algorithm using finite-precision, rounded arithmetic.

    Rounding errors are due to inexactness in the representation of real numbers and the arithmetic operations done with them.

    So what exactly is your problem now?

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

    update

    °) actually I think I already learned it in school in physics classes. The concept is older than CS. I suppose it was introduced a century earlier by Carl Friedrich Gauß.

      A roundoff error, also called rounding error, is the difference between the result produced by a given algorithm using exact arithmetic and the result produced by the same algorithm using finite-precision, rounded arithmetic.

      I didn't realize this was a CS forum. (For some reason I thought it was a perl discussion forum ;-)
      Still, I now better understand where you're coming from.

      If you can now just show us where/how this jargon implies that any of these so-called "errors" should be deemed to be a "flaw", then you'll have presented your case most admirably.

      So what exactly is your problem now?

      Hmmm ... for the moment, my main all-consuming problem is that I'm mortal, and will one day no longer continue to exist :-(
      On the plus side, however, I'm well aware that this problem will go away at some point in the future. (Yay !!!)

      Cheers,
      Rob
        > I didn't realize this was a CS forum.

        And I didn't realize this was an "alternative facts" forum.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

Re^3: Perl 5 numeric type and simplifications
by LanX (Saint) on May 07, 2021 at 12:08 UTC
    What Every Computer Scientist Should Know About Floating-Point Arithmetic

    • Rounding Error
    ... given any fixed number of bits, most calculations with real numbers will produce quantities that cannot be exactly represented using that many bits. Therefore the result of a floating-point calculation must often be rounded in order to fit back into its finite representation. This rounding error is the characteristic feature of floating-point computation. ...

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery