A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Michael wrote:
All numbers except the last one will be exported correctly:
[....]
"><Data ss:Type="Number">68.400000000000006</Data>
Actually, the number is more, not less, precise.
And there is nothing wrong. That is actually the decimal approximation of the binary value that is stored internally in Excel.
The extra decimal places are unexpected, albeit correct, for several reasons.
First, Excel format (displays) only up to the first 15 significant digits (rounded). So the constant 68.4 appears to be 68.400000000000000 even when formatted to display 15 decimal places (17 significant digits).
But numerical values are stored internally using 64-bit binary floating-point, and it requires 17 significant digits to convert between decimal and binary representations with no loss in precision, according to the IEEE 754 standard.
So Excel formats up to the first 17 significant digits (rounded) in the XML file, in part because (compressed) XML is used to repesent saved "xlsx" and "xlsm" Excel files.
The 64-bit binary floating-point representation of numerical values is the sum of 53 powers of 2 ("bits") times an exponential factor. Consequently, most decimal fractions cannot be represented exactly. Moveover (although not relevant for this question), the approximation of the same decimal fraction varies, depending on the magnitude of the integer part.
For example, the decimal approximation of the constant 68.4 is exactly 68.4000000000000,05684341886080801486968994140625, which is 68.400000000000006 when rounded to 17 significant digits.
(I use period for the decimal point and comma to demarcate the first 15 signficant digits.)