Re: factor bug

[email protected] (Philip Newton) Sat, 19 Apr 2014 11:12:00 +0200
Newsgroups perl.ppt
Message-ID <CA+cwSm9_vC2ZSrmd1qj7zjm0kL74Bq5RptHHOCsaHyDbKp1+GA@mail.gmail.com>
On 17 April 2014 02:08, Dave Nunn <[email protected]> wrote:
> The bug is presumably in the line:
> $max-- if $max %2;                   # Make the max odd
> as this does NOT force $max to be odd, but rather even.
> Not sure if the preferred rectification is:
> $max++ unless $max %2;
> -or-
> $max-- unless $max %2;
> though either works for the specific case of 3599.

Or why not replace the "if" clause with "if ($max % 2) == 0".

% is not a boolean operator, and I think that an explicit comparison
will make it clearer what exactly is being tested.

(I have similar feelings about people who write "if(strcmp(foo, bar))" in C.)

Cheers,
Philip
-- 
Philip Newton <[email protected]>