use exponential 'E' format for General when appropriate
Fixes all these test case scenarios: 1. in A1 enter =1E222 * move cell cursor back onto A1 * status bar displays Sum=100000... repeated until filled (or 222 '0' characters) 2. invoke number format dialog on A1 * for General format 100000... is displayed in the preview 3. move cell cursor to A2 * open Function Wizard (Ctrl+F2) * choose (double click) ABS function * enter A1 as parameter * see 100000... displayed as Function result and Result 4. save as .ods * in content.xml see display text of A1 being saved as 100000... Change-Id: I7c22c0461a6783c85c1d51c31e8607fb2edb821c
This commit is contained in:
@@ -54,6 +54,11 @@ char const GREGORIAN[] = "gregorian";
|
|||||||
|
|
||||||
const sal_uInt16 UPPER_PRECISION = 300; // entirely arbitrary...
|
const sal_uInt16 UPPER_PRECISION = 300; // entirely arbitrary...
|
||||||
const double EXP_LOWER_BOUND = 1.0E-4; // prefer scientific notation below this value.
|
const double EXP_LOWER_BOUND = 1.0E-4; // prefer scientific notation below this value.
|
||||||
|
const double EXP_ABS_UPPER_BOUND = 1.0E15; // use exponential notation above that absolute value.
|
||||||
|
// Back in time was E16 that lead
|
||||||
|
// to display rounding errors, see
|
||||||
|
// also sal/rtl/math.cxx
|
||||||
|
// doubleToString()
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@@ -1733,7 +1738,7 @@ void SvNumberformat::ImpGetOutputStandard(double& fNumber, OUString& rOutString)
|
|||||||
{
|
{
|
||||||
sal_uInt16 nStandardPrec = rScan.GetStandardPrec();
|
sal_uInt16 nStandardPrec = rScan.GetStandardPrec();
|
||||||
|
|
||||||
if ( fabs(fNumber) > 1.0E15 ) // #58531# was E16
|
if ( fabs(fNumber) > EXP_ABS_UPPER_BOUND )
|
||||||
{
|
{
|
||||||
nStandardPrec = ::std::min(nStandardPrec, static_cast<sal_uInt16>(14)); // limits to 14 decimals
|
nStandardPrec = ::std::min(nStandardPrec, static_cast<sal_uInt16>(14)); // limits to 14 decimals
|
||||||
rOutString = ::rtl::math::doubleToUString( fNumber,
|
rOutString = ::rtl::math::doubleToUString( fNumber,
|
||||||
@@ -2126,11 +2131,23 @@ bool SvNumberformat::GetOutputString(double fNumber,
|
|||||||
}
|
}
|
||||||
fNumber = -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)
|
||||||
|
{
|
||||||
|
sBuff.append( ::rtl::math::doubleToUString( fNumber,
|
||||||
|
rtl_math_StringFormat_Automatic,
|
||||||
|
rtl_math_DecimalPlaces_Max,
|
||||||
|
GetFormatter().GetNumDecimalSep()[0], true));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
OUString sTemp;
|
OUString sTemp;
|
||||||
ImpGetOutputStdToPrecision(fNumber, sTemp, 10); // Use 10 decimals for general 'unlimited' format.
|
ImpGetOutputStdToPrecision(fNumber, sTemp, 10); // Use 10 decimals for general 'unlimited' format.
|
||||||
sBuff.append(sTemp);
|
sBuff.append(sTemp);
|
||||||
}
|
|
||||||
if (fNumber < EXP_LOWER_BOUND)
|
if (fNumber < EXP_LOWER_BOUND)
|
||||||
{
|
{
|
||||||
sal_Int32 nLen = sBuff.getLength();
|
sal_Int32 nLen = sBuff.getLength();
|
||||||
@@ -2149,6 +2166,7 @@ bool SvNumberformat::GetOutputString(double fNumber,
|
|||||||
GetFormatter().GetNumDecimalSep()[0], true);
|
GetFormatter().GetNumDecimalSep()[0], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (bSign)
|
if (bSign)
|
||||||
{
|
{
|
||||||
sBuff.insert(0, '-');
|
sBuff.insert(0, '-');
|
||||||
|
Reference in New Issue
Block a user