From 224267f36084c3ebf459e4115a406bfd86075c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sat, 18 Dec 2021 17:21:48 +0100 Subject: [PATCH] Fix a bug : don't double '-' sign on negative numbers --- src/uPDFTypes.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/uPDFTypes.cpp b/src/uPDFTypes.cpp index 9de275c..087e308 100644 --- a/src/uPDFTypes.cpp +++ b/src/uPDFTypes.cpp @@ -43,13 +43,9 @@ namespace uPDFParser std::string Integer::str() { std::string sign(""); - if (_signed) - { - if (_value >= 0) - sign = "+"; - else - sign = "-"; - } + // Sign automatically added for negative numbers + if (_signed && _value >= 0) + sign = "+"; return " " + sign + std::to_string(_value); } @@ -57,13 +53,8 @@ namespace uPDFParser std::string Real::str() { std::string sign(""); - if (_signed) - { - if (_value >= 0) - sign = "+"; - else - sign = "-"; - } + if (_signed && _value >= 0) + sign = "+"; return " " + sign + std::to_string(_value); }