Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
If you are using '==' or '!=' on computed floating point values, then you've already lost my sympathy

I, of course, am completely shattered at having lost your sympathy ;-)

... we got tons of complaints because the result of code like ... <snip> ... was not a nice "0.5" but "0.5000000000000002".

The output of that code is *still* not nice, even today. Try it and you'll see.
We need to get the output precision further reduced.

Seriously ... you can reduce the decimal precision of print even further, and that sort of procedure can still produce results that are "not nice":
perl -le "for(1..100000000) {$x += 0.01}print $x;" 1000000.00077928
We need to reduce displayed output to no more than 10 decimal digits ?? (Even less)

The "unniceness" of those results come from cumulatively adding a value that is not precisely 1/100.
I don't see that it has much to do with the decimal precision of print()'s output.

People who can't stand miscounting one grain of sand on their huge beach are a much better choice for who needs to do a tiny bit of extra work

Yes, that's the current state of play. I hope you pointed that out to the people who complained about the output of the snippet you provided.
And I'm sure they were quite happy to do that extra work.

Cheers,
Rob

In reply to Re^5: Variables are automatically rounded off in perl (audiences) by syphilis
in thread Variables are automatically rounded off in perl by Anonymous Monk

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-03-28 10:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found