Skip to content

Commit

Permalink
More to_string optimizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
anOsuPlayer committed Jun 2, 2024
1 parent e1a5581 commit d3a4c9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion nfloat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@

std::string to_string(unsigned int accuracy) {
big_num exp = from_bitset<exp_size>(this->exponent());
if (exp == 0) {
return "0";
}
exp -= _bias(size);

big_num integral = 0, decimal = 1;
Expand All @@ -191,7 +194,7 @@

}
}
else {
if (exp >= 0) {
int_factor /= 2;
}
exp--;
Expand Down
2 changes: 1 addition & 1 deletion test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

int main() {

nfloat<32> f(1.51f);
nfloat<128> f("4342.52");

std::cout << f << "\n";
std::cout << f.to_string(500);
Expand Down

0 comments on commit d3a4c9b

Please sign in to comment.