After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 724568 - ods number roundtrip issues
ods number roundtrip issues
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: import/export OOo / OASIS
git master
Other All
: Normal normal
: ---
Assigned To: Andreas J. Guelzow
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2014-02-17 18:19 UTC by Morten Welinder
Modified: 2014-02-18 04:57 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Morten Welinder 2014-02-17 18:19:40 UTC
New test 6501 shows issues:

Precision is impaired even for integers:

-        <gnm:Cell Row="21" Col="1" ValueType="40">4503599627370496</gnm:Cell>
-        <gnm:Cell Row="21" Col="2" ValueType="40">-4503599627370496</gnm:Cell>
+        <gnm:Cell Row="21" Col="1" ValueType="40">4503599627370500</gnm:Cell>
+        <gnm:Cell Row="21" Col="2" ValueType="40">-4503599627370500</gnm:Cell>


Error constants suffer:

-        <gnm:Cell Row="35" Col="1" ValueType="50">#N/A</gnm:Cell>
+        <gnm:Cell Row="35" Col="1">=#N/A</gnm:Cell>
Comment 1 Andreas J. Guelzow 2014-02-17 22:08:29 UTC
The precision issue is related to how we store the numbers in the ODF file:

        <table:table-row table:style-name="AROW-2">
          <table:table-cell table:style-name="ACE-0xc5f6f8" office:value-type="string"><text:p>2^52</text:p>          </table:table-cell>
          <table:table-cell table:style-name="ACE-0xc5f6f8" office:value-type="float" office:value="4.5035996273705e+15"><text:p>4.50359963E+15</text:p>          </table:table-cell>
          <table:table-cell table:style-name="ACE-0xc5f6f8" office:value-type="float" office:value="-4.5035996273705e+15"><text:p>−4.503600E+15</text:p>          </table:table-cell>
          <table:table-cell table:number-columns-repeated="253" table:style-name="ACE-0xc5f6f8"/>
        </table:table-row>

The issue with the error constants is an ODF limitation. We store:
         <table:table-row table:style-name="AROW-2">
          <table:table-cell table:style-name="ACE-0xc5f6f8" office:value-type="string"><text:p>#N/A</text:p>          </table:table-cell>
          <table:table-cell table:style-name="ACE-0xc5f6f8" table:formula="of:=#N/A" office:value-type="string" office:string-value="#N/A"><text:p>#N/A</text:p>          </table:table-cell>
          <table:table-cell table:number-columns-repeated="254" table:style-name="ACE-0xc5f6f8"/>
        </table:table-row>
Comment 2 Andreas J. Guelzow 2014-02-17 22:16:14 UTC
ODF 1.2 does not have a value type for error constants.

"In an OpenDocument document, if an error value is the result of a cell computation it shall be stored as if it was a string. That is, the office:value-type of an error value is string; if the computed value is stored, it is stored in the attribute office:string-value.
Note: This does not change an Error into a string type (since the Error will be restored on recalculation); this enables applications which cannot recalculate values to display the error information."

The only way to store error constants is by using a formula. The way we store the constant is therefore the only possible.

When we read a formula we could check whether it is just '=#N/A' and convert it to an error constant. Of course in that case if a user indeed wrote'=#N/A' it would also become an error constant. I assume that is preferable.
Comment 3 Morten Welinder 2014-02-18 01:52:46 UTC
I'm ok with the errors either way if ods really can't store it.
Comment 4 Morten Welinder 2014-02-18 01:57:03 UTC
the following calculation from xml-sax-write seems to give the right
precision to use for roundtrips.

	l10 = gnm_log10 (FLT_RADIX);
	res->output.decimal_digits = (int)gnm_ceil (GNM_MANT_DIG * l10) +
		(l10 == (int)l10 ? 0 : 1);
Comment 5 Andreas J. Guelzow 2014-02-18 02:06:28 UTC
I fixed the precision issue earlier today, using that code fromvxml-sax-write.
Comment 6 Andreas J. Guelzow 2014-02-18 04:57:01 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.