From c5c47412d16b5bbdc79886ae9bf93d0158405d14 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Thu, 14 Jan 2016 18:11:39 +0100 Subject: 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 --- svl/source/numbers/zformat.cxx | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'svl') 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); -- cgit