Fix a bug : don't double '-' sign on negative numbers

This commit is contained in:
Grégory Soutadé 2021-12-18 17:21:48 +01:00
parent 5ea898b837
commit 224267f360

View File

@ -43,13 +43,9 @@ namespace uPDFParser
std::string Integer::str() std::string Integer::str()
{ {
std::string sign(""); std::string sign("");
if (_signed) // Sign automatically added for negative numbers
{ if (_signed && _value >= 0)
if (_value >= 0)
sign = "+"; sign = "+";
else
sign = "-";
}
return " " + sign + std::to_string(_value); return " " + sign + std::to_string(_value);
} }
@ -57,13 +53,8 @@ namespace uPDFParser
std::string Real::str() std::string Real::str()
{ {
std::string sign(""); std::string sign("");
if (_signed) if (_signed && _value >= 0)
{
if (_value >= 0)
sign = "+"; sign = "+";
else
sign = "-";
}
return " " + sign + std::to_string(_value); return " " + sign + std::to_string(_value);
} }