diff options
Diffstat (limited to 'libqpdf/QPDF_Real.cc')
-rw-r--r-- | libqpdf/QPDF_Real.cc | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/libqpdf/QPDF_Real.cc b/libqpdf/QPDF_Real.cc index 55f61b35..345f30b6 100644 --- a/libqpdf/QPDF_Real.cc +++ b/libqpdf/QPDF_Real.cc @@ -7,8 +7,8 @@ QPDF_Real::QPDF_Real(std::string const& val) : { } -QPDF_Real::QPDF_Real(double value, int decimal_places, - bool trim_trailing_zeroes) : +QPDF_Real::QPDF_Real( + double value, int decimal_places, bool trim_trailing_zeroes) : val(QUtil::double_to_string(value, decimal_places, trim_trailing_zeroes)) { } @@ -30,23 +30,16 @@ QPDF_Real::getJSON() // converting from string to double and back, just handle this as a // special case for JSON. std::string result; - if (this->val.length() == 0) - { + if (this->val.length() == 0) { // Can't really happen... result = "0"; - } - else if (this->val.at(0) == '.') - { + } else if (this->val.at(0) == '.') { result = "0" + this->val; - } - else if ((this->val.length() >= 2) && - (this->val.at(0) == '-') && - (this->val.at(1) == '.')) - { + } else if ( + (this->val.length() >= 2) && (this->val.at(0) == '-') && + (this->val.at(1) == '.')) { result = "-0." + this->val.substr(2); - } - else - { + } else { result = this->val; } return JSON::makeNumber(result); |