From ef6b1c0dd80a7b37161557aef49d01724f7f7531 Mon Sep 17 00:00:00 2001
From: Olivier Gayot <og@satcom1.com>
Date: Mon, 20 Nov 2017 09:57:56 +0100
Subject: Allow left-shifts of more than 32 bits

Signed-off-by: Olivier Gayot <og@satcom1.com>
---
 number.cpp | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/number.cpp b/number.cpp
index 94ef1ee..c3dd33c 100644
--- a/number.cpp
+++ b/number.cpp
@@ -151,13 +151,22 @@ number::operator*(const number &n) const
 number
 number::operator<<(std::uint32_t shift) const
 {
-    if (shift > 32) {
-        /* TODO */
-        throw std::out_of_range("> 32");
+    if (*this == 0) {
+        return 0;
     }
 
     number result(*this);
 
+    /*
+     * Since, internally, we store 32-bits-wide integers, we can just insert
+     * "shift / 32" new integers at the beginning.
+     */
+    for (unsigned int i = 0; i < shift / 32; ++i) {
+        result._operands.push_front(0);
+    }
+
+    shift %= 32;
+
     std::uint32_t carry = 0;
 
     for (auto &operand: result._operands) {
-- 
cgit v1.2.3