Here are the steps I am following to examine the behavior:
1# Create an Excel(xlsx) file, put 1234.56789 in a cell, save it.
2# Extract the .xlsx file, see the sheet1.xml and styles.xml files.
In the xl/worksheets/Sheet1.xml you will see following:
<sheetData><row r="1" spans="1:1" x14ac:dyDescent="0.25"><c r="A1" s="1"
<v>25778.567889999998</v>
</c></row></sheetData>
And there is no information in the Styles.xml about the precision of the original number which is 1234.56789
.
How does Excel show the original value when we open it in MS Excel?
How does it reconstruct that original number although there is no information in the extracted files?
Note that I did not change the cell format type or anything, so the cell format is General.
I understand that because Excel is storing the number as floating point, it cannot save the value to perfect accuracy, what I can't understand is how it retains the original value when I open that in MS Excel. I am facing an issue regarding reading Excel files using OpenXML SDK, but before asking about that issue I am looking for answer to this more fundamental question.
It just limits input precision to 15 digits, e.g. try to put 25778.567889999955
in cell and see it is immediately converted (in Excel itself) to 25778.5678899999
and 1.23456789123456789
becomes 1.23456789123456
. For more details on numeric representation internals and how it affects calculations see this wonderful wikipedia article.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With