[Libreoffice-commits] core.git: svl/source
Eike Rathke
erack at redhat.com
Thu Jan 14 08:53:43 PST 2016
svl/source/numbers/zformat.cxx | 41 +++++++++++++----------------------------
1 file changed, 13 insertions(+), 28 deletions(-)
New commits:
commit 54862a932fc9ccc1788e91629818ec6666ec1c09
Author: Eike Rathke <erack at redhat.com>
Date: Thu Jan 14 17:42:54 2016 +0100
do it right and remove then superfluous mumbo-jumbo
... that worked around cases where it went wrong.
Change-Id: Icdd4bddfb341a3d0abe4183cf788c546dcddbd00
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index db9cfe8..4daf67b 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2129,41 +2129,26 @@ bool SvNumberformat::GetOutputString(double fNumber,
}
fNumber = -fNumber;
}
- /* TODO: why did we insist on 10 decimals for the non-exponent
- * case? doubleToUString() handles rtl_math_DecimalPlaces_Max
- * gracefully when used with rtl_math_StringFormat_Automatic,
- * so all that special casing and mumbo-jumbo in the else
- * branch below might not be needed at all. */
- if (fNumber > EXP_ABS_UPPER_BOUND)
+ if (fNumber < EXP_LOWER_BOUND)
+ {
+ sBuff.append( ::rtl::math::doubleToUString( fNumber,
+ rtl_math_StringFormat_E2,
+ 15,
+ GetFormatter().GetNumDecimalSep()[0], true));
+ }
+ else if (fNumber < 1.0)
{
sBuff.append( ::rtl::math::doubleToUString( fNumber,
rtl_math_StringFormat_Automatic,
- rtl_math_DecimalPlaces_Max,
+ 15,
GetFormatter().GetNumDecimalSep()[0], true));
}
else
{
- OUString sTemp;
- ImpGetOutputStdToPrecision(fNumber, sTemp, 10); // Use 10 decimals for general 'unlimited' format.
- sBuff.append(sTemp);
- if (fNumber < EXP_LOWER_BOUND)
- {
- sal_Int32 nLen = sBuff.getLength();
- if (!nLen)
- {
- return false;
- }
- // #i112250# With the 10-decimal limit, small numbers are formatted as "0".
- // Switch to scientific in that case, too:
- if (nLen > 11 || ((nLen == 1 && sBuff[0] == '0') && fNumber != 0.0))
- {
- sal_uInt16 nStandardPrec = rScan.GetStandardPrec();
- nStandardPrec = ::std::min(nStandardPrec, static_cast<sal_uInt16>(14)); // limits to 14 decimals
- sBuff = ::rtl::math::doubleToUString( fNumber,
- rtl_math_StringFormat_E2, nStandardPrec /*2*/,
- GetFormatter().GetNumDecimalSep()[0], true);
- }
- }
+ sBuff.append( ::rtl::math::doubleToUString( fNumber,
+ rtl_math_StringFormat_Automatic,
+ rtl_math_DecimalPlaces_Max,
+ GetFormatter().GetNumDecimalSep()[0], true));
}
if (bSign)
{
More information about the Libreoffice-commits
mailing list