diff --git a/bignum.hpp b/bignum.hpp index c29d21f..2fbe3d7 100644 --- a/bignum.hpp +++ b/bignum.hpp @@ -280,9 +280,9 @@ if (!n2 > !n1) { return 0; } if (!n2 == !n1) { return 1; } - big_num result = 0, accumulator; + big_num result = 0, accumulator, factor = !n2; - for (accumulator = 0; (accumulator + !n2) <= n1; accumulator += !n2) { + for (accumulator = 0; (accumulator + factor) <= n1; accumulator += factor) { result++; } @@ -331,7 +331,7 @@ } if (n2 == 2) { - return n1.digits[0] % 2 == 0; + return n1.digits[0] % 2 == 0 ? 0 : 1; } big_num result = 0, accumulator; diff --git a/nfloat.hpp b/nfloat.hpp index 82a0232..f90afc3 100644 --- a/nfloat.hpp +++ b/nfloat.hpp @@ -94,8 +94,8 @@ big_num decimal(decimal_str); long pow = closest_2pow(integral)-1; - __int128_t exp; - + long long exp; + if (pow < 0) { pow = 0; if (decimal != 0) { @@ -114,7 +114,7 @@ *(this->_body) |= to_bitset(integral); *(this->_body) <<= (mant_size - pow); this->_body->reset(mant_size); - } + } if (decimal != 0) { big_num threshold = (big_num(10) ^ decimal_str.length()); diff --git a/test.cpp b/test.cpp index f6b1d8d..983b8ca 100644 --- a/test.cpp +++ b/test.cpp @@ -5,7 +5,7 @@ int main() { - nfloat<32> f = nfloat<32>("0.999999999999999999999"); + big_num n = 125123412313123; - std::cout << f << "\n" << f.to_string(50000); + std::cout << to_bitset<500>(n); } \ No newline at end of file