01-09-2018 05:02 PM
01-09-2018 05:02 PM
I was disturbed with a very strange small decimal amounts (0.0000000000011) somehow added "from the sky" to the result of my formulas . The problem started from the cell highlighted in red in below screen shots.
Help from any one would be appreciated. The original file is attached for your investigation.
|A||B||C||D||E5 = E4-B5+C5|
01-09-2018 07:07 PMSolution
this probably is caused by the floating point precision issue. Read up about that here:
01-09-2018 07:14 PM
I'm also going in circles with your mysterious numbers so no answer from me I'm afraid.
Question though, could you just reduce to two decimal places rather than doing miniscule fractions of cent?
Just another observation for whatever it's worth, you haven't put the debits in the correct column as they are all in the credits column as well as some other strange things in your formula such as column B having a + in front (e.g. =+A6).
Anyway best of luck Grayson, hope it works out!
01-09-2018 08:32 PM
Or watch the video with the ever eloquent Tom Scott.
"And at that point, they will have started to learn about floating point numbers and they will be starting to tear their hair out." OUCH!
01-18-2018 06:25 PM
01-18-2018 06:36 PM
Below is the solution (extracted from the blog, hopefully no copyright problem).
. . .
Let us go back to my very first example where my conditional formatting seemingly did not work. I know now that was due to the fact that the numbers I was using to calculate the absolute difference did not have exact binary equivalents. This resulted in 1.3240 –
There are two basic ways in which you can compensate for some of the errors due to floating point calculation. The first method is to use the ROUND() function. The ROUND() function can be used to round the numbers to the number of decimal places that is required in your calculations. For my absolute difference column, I only require 4 decimals of precision. So I change the formula in the absolute difference column from:
My conditional formatting rule works as expected now since 0.0049999999999999 has been rounded to 0.0050.
The second method to prevent rounding errors from affecting your work is by using the Precision as displayed option. This option forces the value of each number in the worksheet to be the displayed value. To turn on this option, follow these steps:
Going back to my absolute difference example, I set the number format to show four decimal places, and then I turn on Precision as displayed option. Since the display value is the actual value in the cell now, my conditional formatting works properly!
It is important to note that once the workbook is saved, all accuracy beyond four decimal places will be lost. This option affects the active workbook including all worksheets. You cannot undo this option and recover the lost data so save your workbook prior to enabling this option. This option is generally not recommended unless you are sure more precision will not ever be needed for your situation.