Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 13963 - BigInt modulo ulong is rejected #2864

Merged
merged 2 commits into from Jan 25, 2015
Merged

Conversation

e10s
Copy link
Contributor

@e10s e10s commented Jan 11, 2015

For long/ulong, use the implementation of opOpAssign and return BigInt.

https://issues.dlang.org/show_bug.cgi?id=13963

assert(is(typeof(x % 1) == int));
assert(is(typeof(x % 1U) == int));
assert(is(typeof(x % 1L) == BigInt));
assert(is(typeof(x % 1UL) == BigInt));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also add some non-trivial checks to make sure it returns the right value as well? Particularly test how the modulo interacts with positive vs negative on each side.

@e10s
Copy link
Contributor Author

e10s commented Jan 12, 2015

I modified the existing opBinary implementation to return several types.

  • BigInt % long => long
  • BigInt % ulong => BigInt

In the other cases, it returns int. This is the same as before.

@Poita
Copy link
Contributor

Poita commented Jan 12, 2015

LGTM

@andralex
Copy link
Member

Auto-merge toggled on

andralex added a commit that referenced this pull request Jan 25, 2015
Fix Issue 13963 - BigInt modulo ulong is rejected
@andralex andralex merged commit 3fbb2c3 into dlang:master Jan 25, 2015
@e10s e10s deleted the patch-6 branch February 20, 2018 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants