From bebb76e5570a4c496f29fb424f7044df07193074 Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Mon, 22 Jun 2020 16:19:17 -0400 Subject: [PATCH 1/4] make 'a' signed --- math/large_number.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math/large_number.h b/math/large_number.h index bffb764d0..51f8cc528 100644 --- a/math/large_number.h +++ b/math/large_number.h @@ -53,7 +53,7 @@ class large_number { /**< initializer from a string */ explicit large_number(char const *number_str) { for (size_t i = strlen(number_str); i > 0; i--) { - unsigned char a = number_str[i - 1] - '0'; + char a = number_str[i - 1] - '0'; if (a >= 0 && a <= 9) _digits.push_back(a); } From 8862859c18a1017be49d8f960f77abd18c75f9b0 Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Mon, 22 Jun 2020 16:19:59 -0400 Subject: [PATCH 2/4] remove const identifier --- math/large_number.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math/large_number.h b/math/large_number.h index 51f8cc528..521199862 100644 --- a/math/large_number.h +++ b/math/large_number.h @@ -127,7 +127,7 @@ class large_number { /** * Get number of digits in the number **/ - const size_t num_digits() const { return _digits.size(); } + size_t num_digits() const { return _digits.size(); } /** * operator over load to access the From fb82e9050d7708fa0c3b30e5d96c95c21ff520f5 Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Mon, 22 Jun 2020 16:20:27 -0400 Subject: [PATCH 3/4] remove const identifier for function --- math/large_number.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math/large_number.h b/math/large_number.h index 521199862..57154f57b 100644 --- a/math/large_number.h +++ b/math/large_number.h @@ -245,7 +245,7 @@ class large_number { /** * returns i^th digit as an ASCII character **/ - const char digit_char(size_t i) const { + char digit_char(size_t i) const { return _digits[num_digits() - i - 1] + '0'; } From 8736dce71a47f44c5fc62d32287245c4f0e1d790 Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Mon, 22 Jun 2020 16:21:57 -0400 Subject: [PATCH 4/4] make multiplication 64-bit --- math/large_number.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math/large_number.h b/math/large_number.h index 57154f57b..421d8c303 100644 --- a/math/large_number.h +++ b/math/large_number.h @@ -264,7 +264,7 @@ class large_number { size_t i; uint64_t carry = 0, temp; for (i = 0; i < this->num_digits(); i++) { - temp = (*this)[i] * n; + temp = static_cast((*this)[i]) * n; temp += carry; if (temp < 10) { carry = 0;