fixed warnings and errors before moving to abs_sub for integer.cpp

This commit is contained in:
Pagwin 2024-12-11 16:28:59 -05:00
parent 255654b284
commit a1ec5ddaa5
No known key found for this signature in database
GPG key ID: 81137023740CA260

View file

@ -88,10 +88,14 @@ public:
} }
auto idx = true_lhs_size - 1; auto idx = true_lhs_size - 1;
while (idx >= 0) { while (true) {
if (lhs.bytes[idx] != rhs.bytes[idx]) { if (lhs.bytes[idx] != rhs.bytes[idx]) {
return lhs.bytes[idx] < rhs.bytes[idx]; return lhs.bytes[idx] < rhs.bytes[idx];
} }
if (idx == 0) {
break;
}
idx--;
} }
return false; return false;
} }
@ -149,7 +153,7 @@ public:
Integer tmp = std::move(lhs); Integer tmp = std::move(lhs);
Integer tmp_r = rhs; Integer tmp_r = rhs;
lhs = 0; lhs = 0;
while (tmp_r > 0) { while (tmp_r > Integer{0}) {
lhs += tmp; lhs += tmp;
tmp_r -= 1; tmp_r -= 1;
} }
@ -230,8 +234,8 @@ public:
Integer discard = rhs; Integer discard = rhs;
std::stringstream to_output{}; std::stringstream to_output{};
while (discard != 0) { while (discard != Integer{0}) {
to_output << discard % 10; to_output << discard % static_cast<byte>(10);
discard /= 10; discard /= 10;
} }
std::string out; std::string out;
@ -241,7 +245,7 @@ public:
return lhs; return lhs;
} }
explicit operator unsigned long() { operator unsigned long() {
unsigned long ret = 0; unsigned long ret = 0;
for (std::size_t i = 0; i < std::min(size, sizeof(unsigned long)); i++) { for (std::size_t i = 0; i < std::min(size, sizeof(unsigned long)); i++) {
ret += (static_cast<unsigned long>(this->bytes[i]) << (i * 8)); ret += (static_cast<unsigned long>(this->bytes[i]) << (i * 8));