[ooo-build-commit] .: patches/dev300

Kohei Yoshida kohei at kemper.freedesktop.org
Wed May 12 07:29:35 PDT 2010


 patches/dev300/apply                                           |    3 
 patches/dev300/calc-general-type-auto-decimal-ieee754-fix.diff |   35 ++++++++++
 2 files changed, 38 insertions(+)

New commits:
commit 012b1bd633f923ec48800a05d59cc685a8f8253c
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed May 12 10:26:19 2010 -0400

    Adjust the default display format for general number format.
    
    Numbers represented by IEEE 754 double precisions always have
    trailing rounding errors, which makes it impossible to keep or
    strip trailing zeros the mathematically correct way.  We need
    to copromise here.
    
    See i#111533 for more detail.
    
    * patches/dev300/apply:
    * patches/dev300/calc-general-type-auto-decimal-ieee754-fix.diff:

diff --git a/patches/dev300/apply b/patches/dev300/apply
index 6b0611e..cc227a2 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -874,6 +874,9 @@ calc-general-type-auto-decimal-sc-dbf-fix.diff, i#111074, kohei
 # Disable text wrap for numeric values.
 calc-general-type-auto-decimal-disable-linebreak.diff, kohei
 
+# Tweak the default display format to hide the ugliness of IEEE 754 rounding error.
+calc-general-type-auto-decimal-ieee754-fix.diff, i#111533, kohei
+
 # FIXME. hack. readd XclExpInterfaceEnd::WriteBody as in m60 as 
 # calc-xls-export-encryption-condfmt-fix.diff patches it. Kohei, please check
 # --rengelhard
diff --git a/patches/dev300/calc-general-type-auto-decimal-ieee754-fix.diff b/patches/dev300/calc-general-type-auto-decimal-ieee754-fix.diff
new file mode 100644
index 0000000..a509a26
--- /dev/null
+++ b/patches/dev300/calc-general-type-auto-decimal-ieee754-fix.diff
@@ -0,0 +1,35 @@
+diff --git svtools/source/numbers/zformat.cxx svtools/source/numbers/zformat.cxx
+index ab835aa..cf9f7cc 100644
+--- svtools/source/numbers/zformat.cxx
++++ svtools/source/numbers/zformat.cxx
+@@ -1823,15 +1823,15 @@ void SvNumberformat::ImpGetOutputStdToPrecision(double& rNumber, String& rOutStr
+             rtl_math_StringFormat_G, -3, '.', sal_True );
+ }
+ #endif
+-
+-    // If truncating the value to desired precision alters the original value,
+-    // we should show the trailing zeros, otherwise strip them.
+-    double fRounded = ::rtl::math::round(rNumber, nPrecision);
+-    bool bRemoveZeros = ::rtl::math::approxEqual(fRounded, rNumber);
++    
++    // We decided to strip trailing zeros unconditionally, since binary 
++    // double-precision rounding error makes it impossible to determine e.g.
++    // whether 844.10000000000002273737 is what the user has typed, or the
++    // user has typed 844.1 but IEEE 754 represents it that way internally.
+ 
+     rOutString = ::rtl::math::doubleToUString( rNumber,
+             rtl_math_StringFormat_F, nPrecision /*2*/,
+-            GetFormatter().GetNumDecimalSep().GetChar(0), bRemoveZeros );
++            GetFormatter().GetNumDecimalSep().GetChar(0), true );
+     if (rOutString.GetChar(0) == '-' &&
+         rOutString.GetTokenCount('0') == rOutString.Len())
+         rOutString.EraseLeadingChars('-');            // nicht -0
+@@ -2079,7 +2079,7 @@ BOOL SvNumberformat::GetOutputString(double fNumber,
+                     bool bSign = ::rtl::math::isSignBitSet(fNumber);
+                     if (bSign)
+                         fNumber = -fNumber;
+-                    ImpGetOutputInputLine(fNumber, OutString);
++                    ImpGetOutputStdToPrecision(fNumber, OutString, 10); // Use 10 decimals for general 'unlimited' format.
+                     if (fNumber < EXP_LOWER_BOUND)
+                     {
+                         xub_StrLen nLen = OutString.Len();


More information about the ooo-build-commit mailing list