fixed warnings and errors before moving to abs_sub for integer.cpp
This commit is contained in:
parent
255654b284
commit
a1ec5ddaa5
1 changed files with 9 additions and 5 deletions
14
integer.cpp
14
integer.cpp
|
@ -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));
|
||||||
|
|
Loading…
Reference in a new issue