In Excel, when I enter 22222.09482 then I see 22222.0948199999 number in the formula bar
Could you please help - as I have a weird situation that when I enter a number 22222.09482 in cell then I see a different number 22222.0948199999 in the formula bar. Below is the snapshot of the problem.
I see the same behavior when I enter the following numbers:
22222.09482
33333.09482
44444.09482
55555.09482
but when I enter 11111.09482 and 66666.09482, 77777.09482.. until 99999.09482 then they shows correctly. I am not sure is this related to rounding ? I didn't setup any rounding profiles. Could you please help me in resolving the issue.
Solution 1:
It is a bug.
Excel uses the usual IEEE double-precision representation, according to other answers. Its precision is 53 significant binary digits, which corresponds to roughly 16 decimal digits.
It is always "safe" to display the first 15 significant decimal digits. In the sense that any decimally "presented" number given with 15 digits can be safely distinguished from the numbers obtained by changing the 15th decimal figure by one. For example, the 15-digit numbers:
22222.09481 99999
22222.09482 00000
22222.09482 00001
map to three distinct double-precision numbers. None of these three will be "neighbors" in the double-precision representation, in this particular case.
So, confusing the first two in the user display, is a bug of Excel.
In fact, in this domain (between 16384 and 32768), the absolute precision is 2-38, and the following numbers are representable:
...
22222.09481 99998 96571 9714760780334472656250000
22222.09481 99999 00209 9502831697463989257812500 <-- the one closest to what Excel showed to the user
22222.09481 99999 03847 9290902614593505859375000
22222.09481 99999 07485 9078973531723022460937500
22222.09481 99999 11123 8867044448852539062500000
22222.09481 99999 14761 8655115365982055664062500
22222.09481 99999 18399 8443186283111572265625000
22222.09481 99999 22037 8231257200241088867187500
22222.09481 99999 25675 8019328117370605468750000
22222.09481 99999 29313 7807399034500122070312500
22222.09481 99999 32951 7595469951629638671875000
22222.09481 99999 36589 7383540868759155273437500
22222.09481 99999 40227 7171611785888671875000000
22222.09481 99999 43865 6959682703018188476562500
22222.09481 99999 47503 6747753620147705078125000
22222.09481 99999 51141 6535824537277221679687500
22222.09481 99999 54779 6323895454406738281250000
22222.09481 99999 58417 6111966371536254882812500
22222.09481 99999 62055 5900037288665771484375000
22222.09481 99999 65693 5688108205795288085937500
22222.09481 99999 69331 5476179122924804687500000
22222.09481 99999 72969 5264250040054321289062500
22222.09481 99999 76607 5052320957183837890625000
22222.09481 99999 80245 4840391874313354492187500
22222.09481 99999 83883 4628462791442871093750000
22222.09481 99999 87521 4416533708572387695312500
22222.09481 99999 91159 4204604625701904296875000
22222.09481 99999 94797 3992675542831420898437500
22222.09481 99999 98435 3780746459960937500000000 <-- the one closest to what the user types
22222.09482 00000 02073 3568817377090454101562500
22222.09482 00000 05711 3356888294219970703125000
22222.09482 00000 09349 3144959211349487304687500
22222.09482 00000 12987 2933030128479003906250000
22222.09482 00000 16625 2721101045608520507812500
22222.09482 00000 20263 2509171962738037109375000
22222.09482 00000 23901 2297242879867553710937500
22222.09482 00000 27539 2085313796997070312500000
22222.09482 00000 31177 1873384714126586914062500
22222.09482 00000 34815 1661455631256103515625000
22222.09482 00000 38453 1449526548385620117187500
22222.09482 00000 42091 1237597465515136718750000
22222.09482 00000 45729 1025668382644653320312500
22222.09482 00000 49367 0813739299774169921875000
22222.09482 00000 53005 0601810216903686523437500
22222.09482 00000 56643 0389881134033203125000000
22222.09482 00000 60281 0177952051162719726562500
22222.09482 00000 63918 9966022968292236328125000
22222.09482 00000 67556 9754093885421752929687500
22222.09482 00000 71194 9542164802551269531250000
22222.09482 00000 74832 9330235719680786132812500
22222.09482 00000 78470 9118306636810302734375000
22222.09482 00000 82108 8906377553939819335937500
22222.09482 00000 85746 8694448471069335937500000
22222.09482 00000 89384 8482519388198852539062500
22222.09482 00000 93022 8270590305328369140625000
22222.09482 00000 96660 8058661222457885742187500
22222.09482 00001 00298 7846732139587402343750000
...
To elaborate further, try typing 22222.09482
in one cell, and typing 22222.0948199999
(five trailing nines) in another cell. Excel should pick the two IEEE representatives indicated by the arrow above. And I think it does, because you can calculate the difference of these two cells to get 9.82254E-11
. But both are shown in the same way.
If Excel had shown the first 17 digits, that would be helpful to pick out exactly what IEEE number is "underneath" the decimal number. In that case:
22222.0948199999 --> 22222.09481 99999 00
22222.09482 --> 22222.09481 99999 98
But showing 15 digits rounded in an incorrect way, is misleading and unhelpful.
Before anyone claims it is intentional, then why does 8.7
not show the same behavior? The nearest double-precision number to 8.7
is:
8.69999999999999 93
so it should show as 8.69999999999999
if this was intentional. But it does not.
Solution 2:
Excel stores numbers in IEEE 754 binary 64-bit floating point format. The key is "stores" - the change from decimal to binary takes place whenever a number is stored, not just when it is used in an actual calculation.
A nice article on this is at Understanding Floating Point Precision, aka “Why does Excel Give Me Seemingly Wrong Answers?”
It is possible to make a spreadsheet program that would handle really big numbers with a lot of significant digits. But it isn't terribly practical. Excel could have been designed to use the IEEE 754 decimal128 format, which allows for 34 decimal digits - more than enough to store 22222.09482. But instead it uses the far more common binary64 Double Precision format, which has 53 bits of precision, which is just under 16 digits. While you might think that would be enough for a number with only 10 digits in it, conversion from decimal to binary complicates things a bit - i.e., 2222209482 can be stored 100% correctly as a binary64 number, but 22222.09482 can not.
Keep in mind that typically spreadsheets are used for financial data, which typically does not require so many digits of precision, or for "what if" modeling in a variety of scenarios, where a super-high level of precision is not needed. There are certainly other tools (and probably other spreadsheet programs, but I haven't searched lately) that either by default or by special configuration settings can use a larger numeric format, but Excel isn't one of them.
For those who point out that LibreOffice handles this better, looks can be deceiving. See this post for more details. It seems that LibreOffice handles large numbers slightly differently but has the same basic 64-bit floating point representation with similar problems.