Relative presision removes the need to specify a precision (so it's easier to use), but it has limits.

For example, most numbers in the real-time control system on which I work are have a range of 0 to 1 (inclusive). Some of the numbers with which I deal are measurements of valve positions. 0 means the valve is fully closed, 0.25 means it's one quarter open, and 1 means it's fully open. If we were to compare two valve positions, we'd consider 4/1000th open and 5/1000th open equal. Because relative precision has no idea these measurements are tiny compared to the range, it would consider them unequal.

In my experience (in the real-time control systems world), relative presision should only be avoided whenever possible. Absolute precision should be used instead.

Update:

Oddly enough, we rarely use any kind of tolerance in our system except during automated testing. Equality checks are rarely if ever needed. Inequalities, on the other hand, are used throughout. We use deadbands to avoid jitter.

if ($x < 0.5) { # All is ok $ok = 1; ... normal operation mode ... } elsif ($x > 0.7) { # Things are definitely bad. $ok = 0; ... exceptional operation mode ... } elsif ($ok) { # In deadband. Was last ok. ... normal operation mode ... } else { # In deadband. Was last bad. ... exceptional operation mode ... }

In reply to Re^4: Infinite loop but no reason why by ikegami
in thread Infinite loop but no reason why 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":



  • 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, details, 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, summary, 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.