Skip to content

Use long-long integer constant as the left-hand side is long long #2458

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

Merged
merged 1 commit into from
Jun 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/util/mp_arith.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ mp_integer arith_left_shift(
llong_t result=a.to_long()<<shift;
llong_t mask=
true_size<(sizeof(llong_t)*8) ?
(1L<<true_size)-1 :
(1LL << true_size) - 1 :
-1;
return result&mask;
}
Expand All @@ -281,8 +281,8 @@ mp_integer arith_right_shift(
if(shift>true_size)
throw "shift value out of range";

llong_t sign=(1<<(true_size-1))&number;
llong_t pad=(sign==0) ? 0 : ~((1<<(true_size-shift))-1);
const llong_t sign = (1LL << (true_size - 1)) & number;
const llong_t pad = (sign == 0) ? 0 : ~((1LL << (true_size - shift)) - 1);
llong_t result=(number >> shift)|pad;
return result;
}
Expand All @@ -302,8 +302,8 @@ mp_integer logic_left_shift(
llong_t result=a.to_long()<<shift;
if(true_size<(sizeof(llong_t)*8))
{
llong_t sign=(1L<<(true_size-1))&result;
llong_t mask=(1L<<true_size)-1;
const llong_t sign = (1LL << (true_size - 1)) & result;
const llong_t mask = (1LL << true_size) - 1;
// Sign-fill out-of-range bits:
if(sign==0)
result&=mask;
Expand Down Expand Up @@ -345,7 +345,7 @@ mp_integer rotate_right(
throw "shift value out of range";

ullong_t revShift=true_size-shift;
ullong_t filter=1<<(true_size-1);
const ullong_t filter = 1ULL << (true_size - 1);
ullong_t result=(number >> shift)|((number<<revShift)&filter);
return result;
}
Expand All @@ -365,7 +365,7 @@ mp_integer rotate_left(
throw "shift value out of range";

ullong_t revShift=true_size-shift;
ullong_t filter=1<<(true_size-1);
const ullong_t filter = 1ULL << (true_size - 1);
ullong_t result=((number<<shift)&filter)|((number&filter) >> revShift);
return result;
}