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

Make Shr for negative BigInt round down, like primitives do #8

Merged
merged 2 commits into from
Feb 24, 2018

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Dec 19, 2017

Primitive integers always round down when shifting right, but BigInt
was effectively rounding toward zero, because it just kept its sign and
used the BigUint magnitude rounded down (always toward zero).

Now we adjust the result of shifting negative values, and explicitly
test that it matches the result for primitive integers.

Fixes #1.

Primitive integers always round down when shifting right, but `BigInt`
was effectively rounding toward zero, because it just kept its sign and
used the `BigUint` magnitude rounded down (always toward zero).

Now we adjust the result of shifting negative values, and explicitly
test that it matches the result for primitive integers.
@cuviper
Copy link
Member Author

cuviper commented Feb 24, 2018

bors r+

bors bot added a commit that referenced this pull request Feb 24, 2018
8: Make Shr for negative BigInt round down, like primitives do r=cuviper a=cuviper

Primitive integers always round down when shifting right, but `BigInt`
was effectively rounding toward zero, because it just kept its sign and
used the `BigUint` magnitude rounded down (always toward zero).

Now we adjust the result of shifting negative values, and explicitly
test that it matches the result for primitive integers.

Fixes #1.
@bors
Copy link
Contributor

bors bot commented Feb 24, 2018

Build succeeded

@bors bors bot merged commit b315c01 into rust-num:master Feb 24, 2018
dingelish pushed a commit to mesalock-linux/num-bigint-sgx that referenced this pull request Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant