Skip to content

Commit

Permalink
Fix Real::toString
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Apr 8, 2024
1 parent ee66ed5 commit 21e5d7f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/fintamath/numbers/Real.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,7 @@ Real::Real(const Integer &rhs)
isNegative(rhs < 0) {}

std::string Real::toString() const noexcept {
std::string res = toString(outputPrecision);

if (isNegative && res.front() != '-') {
res.insert(res.begin(), '-');
}

return res;
return toString(outputPrecision);
}

std::string Real::toString(unsigned precision) const noexcept {
Expand Down Expand Up @@ -122,6 +116,10 @@ std::string Real::toString(unsigned precision) const noexcept {
str.erase(str.size() - 2, 2);
}

if (isNegative && str.front() != '-') {
str.insert(str.begin(), '-');
}

return str;
}

Expand Down

0 comments on commit 21e5d7f

Please sign in to comment.