GNOME Bugzilla – Bug 724568
ods number roundtrip issues
Last modified: 2014-02-18 04:57:01 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>
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>
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.
I'm ok with the errors either way if ods really can't store it.
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);
I fixed the precision issue earlier today, using that code fromvxml-sax-write.
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.