Ellhar:

It looks like you're overcomplicating things. By looking over your code, it looks like you really want something like this (untested!):

$a= 20; $b= 22.5; $c= 23 $atob = abs($a - $b) > 1 ? 1 : 0; $btoc = abs($b - $c) > 1 ? 1 : 0; $atoc = abs($a - $c) > 1 ? 1 : 0; if ( $atob && $atoc && $btoc ) { print OUTFILE "DIFF > 1 all three\n"; $matrixflags[$row - 4][$i] = 1; $matrixflags[$row - 3][$i] = 1; $matrixflags[$row - 2][$i] = 1; } ...
That would also help you avoid some of the impossible conditions in your code, like:

((btoc < 1) && (btoc > -1))
You should always try to simplify your logic before writing your code!

...roboticus

Update: After another second of thought, perhaps this would be even more to your liking--Replace the if .. then stuff with:

if ($atob+$atoc+$btoc) { printf OUTFILE "DIFF=%d: %f, %f, %f\n", $atob+$atoc+$btoc, $a-$b, $a-$c, $b-$c; } $matrixflags[$row - 4][$i] = $atob; $matrixflags[$row - 3][$i] = $atoc; $matrixflags[$row - 2][$i] = $atob; }

In reply to Re: if logic OR parentheses problem by roboticus
in thread if logic OR parentheses problem by Ellhar

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.