Skip to content

Commit

Permalink
Fix compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Herts committed Sep 16, 2024
1 parent 4bb61ae commit f76f59a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions bigint.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include <string>
#include <sstream>
#include <utility>
#include <vector>
#include <cmath>
#include <limits>
Expand Down Expand Up @@ -111,9 +112,9 @@ namespace BigInt {

bigint(const bigint &n) { *this = n; }

bigint(const char* string) : bigint(std::string(string)) {}
bigint(const char* n) : bigint(std::string(n)) {}

bigint(std::vector<long long> n) {this->vec = n;}
bigint(std::vector<long long> n) {this->vec = std::move(n);}

bigint& operator=(const bigint& other)
{
Expand Down Expand Up @@ -493,7 +494,7 @@ namespace BigInt {
std::transform(lhs.vec.rbegin(), lhs.vec.rend(), full_rhs.vec.rbegin(), carry_result.rbegin(), add_with_carry);

std::vector<long long> final(lhs.vec.size() + 1);
for (int i = carry_result.size() - 1; i >= 0; --i) {
for (auto i = carry_result.size() - 1; i >= 0; --i) {
final[i] += carry_result[i].second;
final[i - 1] += carry_result[i].first;
}
Expand Down Expand Up @@ -551,7 +552,7 @@ namespace BigInt {
subtract_with_borrow);

std::vector<long long> final(lhs.vec.size());
for (int i = borrow_result.size() - 1; i >= 0; --i) {
for (auto i = borrow_result.size() - 1; i >= 0; --i) {
final[i] += borrow_result[i].second;
if (borrow_result[i].first)
final[i - 1] -= borrow_result[i].first;
Expand Down Expand Up @@ -759,7 +760,10 @@ namespace BigInt {

inline bigint bigint::logwithbase(const bigint &input, const bigint &base)
{
return divide(log2(input), log2(base));
auto top = log2(input);
auto bottom = log2(base);
auto answer = divide(top, bottom);
return answer;
}

inline bigint bigint::antilog2(const bigint &input)
Expand Down Expand Up @@ -896,7 +900,7 @@ namespace BigInt {

int bigint::count_digits(const bigint & input) {
std::string my_string = vector_to_string(input.vec);
return my_string.length() - 1;
return static_cast<int>(my_string.length()) - 1;
}

} // namespace::BigInt
Expand Down

0 comments on commit f76f59a

Please sign in to comment.