Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Floating-point arithmetic is flawed and sucks, and has sucked for probably 40+ years by now (which is really a very long period when speaking about modern technologies). It is actually outrageous that this hasn't been fixed over such a long period. Experienced programmers know it and have been accustomed to live with that. Does that mean that we should accept this flaw? I don't think so. IMHO, we should get rid of that flaw, we need a flexit.

Consider this in Python:

>>> .3 - .2 - .1 -2.7755575615628914e-17
The result is very small, but it should really be 0.

It's not better in Perl 5:

$ perl -E 'say .3 - .2 - .1;' -2.77555756156289e-17
Of course, neither Python nor Perl 5 is responsible for that, it is the FP arithmetic of the underlying architecture which sucks.

Does this mean we can't do anything about it? Yes, we can, Perl 6 has this right:

> say .3 - .2 - .1; 0 > printf "%.50f\n", .3 - .2 - .1; 0.00000000000000000000000000000000000000000000000000
Getting an accurate result for such a simple calculation is not anecdotal. It is a real and major improvement. You can compare non integers for equality and get the correct result. Don't do that with most other programming languages.

Yes, this improvement comes with a cost. So long as we have hardware that is inaccurate, we'll need to work around it with software, and this is bound to be somewhat slower. Personally, I think that accuracy is more important than speed.

If speed was the only criteria, none of us would use Perl, we would all write our programs in C, nay, probably in assembly. But we don't. So, most of the time, speed is not the most important factor for us.

Well, sometimes, speed matters. And I probably would not argue for accuracy if that meant that computation was really "insanely slow," as you claim. But it is not insanely slow; it is just somewhat slower, as shown in my earlier post above, and this speed issue could just be solved with a faster CPU. And, as I said earlier, there are performance enhancements almost every week (and some very big ones should be there very soon).

In reply to Re^3: Reasons for Using Perl 6 by Laurent_R
in thread Reasons for Using Perl 6 by aartist

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [choroba]: Good morning!

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (6)
    As of 2018-06-21 07:32 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (117 votes). Check out past polls.