Skip to content

Fix issue #288#292

Merged
heyLu merged 6 commits into
pixie-lang:masterfrom
MatthewWest:master
Apr 22, 2015
Merged

Fix issue #288#292
heyLu merged 6 commits into
pixie-lang:masterfrom
MatthewWest:master

Conversation

@MatthewWest
Copy link
Copy Markdown

Only extend the rem operation to use math.fmod if one or both of the
two arguments is not an integer.

Fixes #288

Only extend the rem operation to use math.fmod if one or both of the
two arguments is not an integer.
@MatthewWest MatthewWest mentioned this pull request Apr 20, 2015
Comment thread pixie/vm/numbers.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must be an and, not an or, otherwise some operations are not defined.

I think _quot could be included in this if-statement as well, because it also has a special case defined above.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually doesn't though. See, it's checking for whether either is not an integer. That is functionally identical to checking whether it is not the case that both are integers. Unless there's something else I'm not thinking of.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, sorry.

Can you include _quot as well, though?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@halgari
Copy link
Copy Markdown
Member

halgari commented Apr 20, 2015

I'm fine with this patch, but I'd like a few tests around the results of this patch, just to verify the behavior is what we expect. I'll merge at that point.

@andrewchambers
Copy link
Copy Markdown
Contributor

Yeah, clearly this issue is possible because no one is writing any numeric code with pixie yet. I found it while solving project Euler problem 1.

@MatthewWest
Copy link
Copy Markdown
Author

I just added a few tests that I think handle all the possible cases, or at least most of them. All the tests are passing.

Interesting fun fact: quot returns Integer, even with fed with two ratio arguments, because it is the nearest integer quotient. Very logical!

@MatthewWest
Copy link
Copy Markdown
Author

Thanks @thomasmulvaney I fixed it to not use stringification.

Comment thread tests/pixie/tests/test-numbers.pxi Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix these asserts as well?

@MatthewWest
Copy link
Copy Markdown
Author

@heyLu Done.

@halgari
Copy link
Copy Markdown
Member

halgari commented Apr 22, 2015

Looks great, we'll merge this as soon as the build finishes

heyLu added a commit that referenced this pull request Apr 22, 2015
@heyLu heyLu merged commit 55a257b into pixie-lang:master Apr 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integer remainder

4 participants