summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-01-14 17:42:54 +0100
committerEike Rathke <erack@redhat.com>2016-01-14 17:52:59 +0100
commit54862a932fc9ccc1788e91629818ec6666ec1c09 (patch)
treec1a5a773c81736061f3ffc4065b2e429df350eb0
parent98887155c0fd209ed60e181f745bf00fb2d69ab7 (diff)
do it right and remove then superfluous mumbo-jumbo
... that worked around cases where it went wrong. Change-Id: Icdd4bddfb341a3d0abe4183cf788c546dcddbd00
-rw-r--r--svl/source/numbers/zformat.cxx41
1 files changed, 13 insertions, 28 deletions
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index db9cfe8b97e3..4daf67bf05e0 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)
{