diff options
author | Eike Rathke <erack@redhat.com> | 2016-01-14 18:11:39 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-01-14 18:14:23 +0100 |
commit | c5c47412d16b5bbdc79886ae9bf93d0158405d14 (patch) | |
tree | 4d3356472e03dd61e4faabeec6f0574a69f573b2 /svl | |
parent | 54862a932fc9ccc1788e91629818ec6666ec1c09 (diff) |
it's unnecessary to buffer the string to create a string from it again
... just in case there was a negative number and a minus to be inserted.
doubleToUString() does it already.
Change-Id: I0052d7bc91b48efb5f14f2f6f5a7c672a1e50ea9
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/numbers/zformat.cxx | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 4daf67bf05e0..6d80c53bedd1 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -2120,41 +2120,32 @@ bool SvNumberformat::GetOutputString(double fNumber, case css::util::NumberFormat::NUMBER: // Standard number format if (rScan.GetStandardPrec() == SvNumberFormatter::UNLIMITED_PRECISION) { - bool bSign = ::rtl::math::isSignBitSet(fNumber); - if (bSign) + if (::rtl::math::isSignBitSet(fNumber)) { if (!(fNumber < 0.0)) - { - bSign = false; - } - fNumber = -fNumber; + fNumber = -fNumber; // do not display -0.0 } - if (fNumber < EXP_LOWER_BOUND) + if (fNumber < EXP_LOWER_BOUND && fNumber > -EXP_LOWER_BOUND) { - sBuff.append( ::rtl::math::doubleToUString( fNumber, + OutString = ::rtl::math::doubleToUString( fNumber, rtl_math_StringFormat_E2, 15, - GetFormatter().GetNumDecimalSep()[0], true)); + GetFormatter().GetNumDecimalSep()[0], true); } - else if (fNumber < 1.0) + else if (fNumber < 1.0 && fNumber > -1.0) { - sBuff.append( ::rtl::math::doubleToUString( fNumber, + OutString = ::rtl::math::doubleToUString( fNumber, rtl_math_StringFormat_Automatic, 15, - GetFormatter().GetNumDecimalSep()[0], true)); + GetFormatter().GetNumDecimalSep()[0], true); } else { - sBuff.append( ::rtl::math::doubleToUString( fNumber, + OutString = ::rtl::math::doubleToUString( fNumber, rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - GetFormatter().GetNumDecimalSep()[0], true)); - } - if (bSign) - { - sBuff.insert(0, '-'); + GetFormatter().GetNumDecimalSep()[0], true); } - OutString = sBuff.makeStringAndClear(); return false; } ImpGetOutputStandard(fNumber, sBuff); |