From a1ec5ddaa5dd17ca3acff98cdc2b374c7a2dfd00 Mon Sep 17 00:00:00 2001 From: Pagwin Date: Wed, 11 Dec 2024 16:28:59 -0500 Subject: [PATCH] fixed warnings and errors before moving to abs_sub for integer.cpp --- integer.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/integer.cpp b/integer.cpp index 3b26cc6..0a8c544 100644 --- a/integer.cpp +++ b/integer.cpp @@ -88,10 +88,14 @@ public: } auto idx = true_lhs_size - 1; - while (idx >= 0) { + while (true) { if (lhs.bytes[idx] != rhs.bytes[idx]) { return lhs.bytes[idx] < rhs.bytes[idx]; } + if (idx == 0) { + break; + } + idx--; } return false; } @@ -149,7 +153,7 @@ public: Integer tmp = std::move(lhs); Integer tmp_r = rhs; lhs = 0; - while (tmp_r > 0) { + while (tmp_r > Integer{0}) { lhs += tmp; tmp_r -= 1; } @@ -230,8 +234,8 @@ public: Integer discard = rhs; std::stringstream to_output{}; - while (discard != 0) { - to_output << discard % 10; + while (discard != Integer{0}) { + to_output << discard % static_cast(10); discard /= 10; } std::string out; @@ -241,7 +245,7 @@ public: return lhs; } - explicit operator unsigned long() { + operator unsigned long() { unsigned long ret = 0; for (std::size_t i = 0; i < std::min(size, sizeof(unsigned long)); i++) { ret += (static_cast(this->bytes[i]) << (i * 8));