For the range 0 to 1, then epsilon will always be greater than the error

So while we have the example of 0.8 down to 0.1, the difference between the epsilon and the ULP won't be huge. But who knows whether the OP will eventually go beyond that range, and get upset when numbers near 2e-16 start displaying as near 4e-16. That's one of the reasons I was cautioning against applying epsilon in this case, because it might later be generalized to a condition where it's not even close to the real absolute error.

Print rounds down

that's not true, as syphilis showed. Here's another example.

C:\usr\local\share>perl -le "printf qq(%.17e => %s\n), $_, $_ for 2.99 +999999999999989e-02, 2.99999999999999503e-02, 2.99999999999999468e-02 +" 2.99999999999999989e-02 => 0.03 2.99999999999999503e-02 => 0.03 2.99999999999999468e-02 => 0.0299999999999999

Print rounds to nearest to the precision that print "likes" rounding to.

If the float is +/- epsilon from ideal, then adding an epsiol brings it into range of 0 to +2 epsilon from ideal, which will round down to ideal.

Again, no.

C:\usr\local\share>perl -MMachine::Epsilon -le "for (2.999999999999999 +89e-02, 2.99999999999999503e-02, 2.99999999999999468e-02) { printf qq +(%.17e => %-30s x+2eps = %s\n), $_, $_, $_+2*machine_epsilon}" 2.99999999999999989e-02 => 0.03 x+2eps = 0.0 +300000000000004 2.99999999999999503e-02 => 0.03 x+2eps = 0.0 +300000000000004 2.99999999999999468e-02 => 0.0299999999999999 x+2eps = 0.0 +300000000000004

Notice that x+2epsilon prints a number bigger than 0.03, whereas the value of x is slightly less than 0.03 (by 1 ULP).


In reply to Re^4: what did I just see..? by pryrt
in thread what did I just see..? by ishaybas

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 or How to display code and escape characters are good places to start.