Skip to content

Commit

Permalink
More fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
anOsuPlayer committed Apr 30, 2024
1 parent 0779c9b commit dabde44
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions bignum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}

Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions nfloat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -114,7 +114,7 @@
*(this->_body) |= to_bitset<size>(integral);
*(this->_body) <<= (mant_size - pow);
this->_body->reset(mant_size);
}
}

if (decimal != 0) {
big_num threshold = (big_num(10) ^ decimal_str.length());
Expand Down
4 changes: 2 additions & 2 deletions test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit dabde44

Please sign in to comment.