aboutsummaryrefslogtreecommitdiff
path: root/src/big_int.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-10-28 09:32:59 +0000
committergingerBill <bill@gingerbill.org>2018-10-28 09:32:59 +0000
commitdfd7a194ed042083db93826b7fbc88d43290ed05 (patch)
tree9a8d7b09b5bf8a57921c814c1b1be9bd47362fab /src/big_int.cpp
parent2ddb27869bd704d28e4704648c26b17d00ba2ff5 (diff)
Fix big int shifts of 0
Diffstat (limited to 'src/big_int.cpp')
-rw-r--r--src/big_int.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/big_int.cpp b/src/big_int.cpp
index be4f2cdc1..8a64fbf21 100644
--- a/src/big_int.cpp
+++ b/src/big_int.cpp
@@ -554,6 +554,16 @@ void big_int_sub(BigInt *dst, BigInt const *x, BigInt const *y) {
void big_int_shl(BigInt *dst, BigInt const *x, BigInt const *y) {
GB_ASSERT(!y->neg);
+ if (x->len == 0) {
+ big_int_from_u64(dst, 0);
+ return;
+ }
+
+ if (x->len == 1 && x->d.word == 0) {
+ big_int_from_u64(dst, 0);
+ return;
+ }
+
if (y->len == 0) {
big_int_init(dst, x);
return;
@@ -605,6 +615,10 @@ void big_int_shr(BigInt *dst, BigInt const *x, BigInt const *y) {
big_int_from_u64(dst, 0);
return;
}
+ if (x->len == 1 && x->d.word == 0) {
+ big_int_from_u64(dst, 0);
+ return;
+ }
if (y->len == 0) {
big_int_init(dst, x);