Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

about_math, modulus, even or odd #18

Open
muraiki opened this issue Mar 9, 2014 · 3 comments
Open

about_math, modulus, even or odd #18

muraiki opened this issue Mar 9, 2014 · 3 comments

Comments

@muraiki
Copy link

muraiki commented Mar 9, 2014

In the section of about_math.pl dealing with modulus and using it to determine if a number is even or odd, I found it interesting that to get the tests to pass requires an odd number for $even and an even number for $odd. Is this intentional? Or maybe I'm just missing something here!

my $even = 3;
my $odd  = 2;
is ($even % 2, 1, "modulus is often used to determine even/odd");
is ($odd  % 2, 0, "modulus is often used to determine even/odd - part 2");
@chorankates
Copy link

@muraiki you're absolutely correct, this test is backwards.. even number mod 2 is 0. i'm fairly certain i've already fixed this in the 'fixing' branch, but i just haven't pushed it up yet, will leave this open until i can track down the commit.

thanks for noticing!

@muraiki
Copy link
Author

muraiki commented Mar 11, 2014

I didn't notice that there was a fixing branch -- sorry!

On Mon, Mar 10, 2014 at 12:21 PM, Conor Horan-Kates <
[email protected]> wrote:

@muraiki https://github.com/muraiki you're absolutely correct, this
test is backwards.. even number mod 2 is 0. i'm fairly certain i've already
fixed this in the 'fixing' branch, but i just haven't pushed it up yet,
will leave this open until i can track down the commit.

thanks for noticing!

Reply to this email directly or view it on GitHubhttps://github.com//issues/18#issuecomment-37201550
.

@chorankates
Copy link

pushed some changes to about_math.pl in 1b1c0ab, it's not exactly the same test anymore, but does not contain the mistake you mention.

maybe we should provide defined values for $even and $odd?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants