Ellhar has asked for the wisdom of the Perl Monks concerning the following question:
During debugging the values seem to make sense but I’m not executing the any of the statements. Any ideas? Thanks Elliott$a= 20; $b= 22.5; $c= 23 $atob = $a - $b; $btoc = $b - $c; $atoc = $a - $c; if (((atob > 1 ) || (atob < -1)) && ((atoc > 1) || (atoc < -1)) && ((b +toc > 1) || (btoc < -1))) { print OUTFILE "DIFF > 1 all three\n"; $matrixflags[$row - 4][$i] = 1; $matrixflags[$row - 3][$i] = 1; $matrixflags[$row - 2][$i] = 1; } elsif (((atob > 1) || (atob < -1)) && ((btoc < 1) && (btoc > -1)) && ( +(atoc > 1) || (atoc < -1))) { print OUTFILE "DIFFA > 1 $atob $atoc $btoc\n"; $matrixflags[$row - 4][$i] = 1; $matrixflags[$row - 3][$i] = 0; $matrixflags[$row - 2][$i] = 0; } elsif (((atob > 1) || (atob < -1)) && ((btoc > 1) || (btoc < -1)) && ( +(atoc < 1) && (atoc > -1))) { print OUTFILE "DIFFB > 1 $atob $atoc $btoc\n"; $matrixflags[$row - 4][$i] = 0; $matrixflags[$row - 3][$i] = 1; $matrixflags[$row - 2][$i] = 0; } elsif (((atob < 1) && (atob > -1)) && ((btoc > 1) || (btoc < -1)) && ( +(atoc > 1) || (atoc < -1))) { print OUTFILE "DIFFC > 1 $atob $atoc $btoc\n"; $matrixflags[$row - 4][$i] = 0; $matrixflags[$row - 3][$i] = 0; $matrixflags[$row - 2][$i] = 1; } #So in this example in my head the 1st elsif should be executed. #Difference $atob = 1.5 so ((atob > 1) || (atob < -1)) is true. #Difference $btoc = 0.5 so ((btoc < 1) && (btoc > -1)) is true. #Difference $atoc = 3 so ((atoc > 1) || (atoc < -1)) is true.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: if logic OR parentheses problem
by FunkyMonk (Bishop) on Oct 26, 2007 at 14:12 UTC | |
by Ellhar (Novice) on Oct 26, 2007 at 15:54 UTC | |
|
Re: if logic OR parentheses problem
by Corion (Patriarch) on Oct 26, 2007 at 14:14 UTC | |
|
Re: if logic OR parentheses problem
by gamache (Friar) on Oct 26, 2007 at 14:18 UTC | |
by johngg (Canon) on Oct 26, 2007 at 15:40 UTC | |
by gamache (Friar) on Oct 26, 2007 at 16:09 UTC | |
|
Re: if logic OR parentheses problem
by papidave (Pilgrim) on Oct 26, 2007 at 15:53 UTC | |
|
Re: if logic OR parentheses problem
by roboticus (Chancellor) on Oct 26, 2007 at 21:41 UTC | |
|
Re: if logic OR parentheses problem
by talexb (Chancellor) on Oct 26, 2007 at 15:03 UTC |