(A - B) is not equal to A - B, apparently

edward_glyver

New Member
Joined
Jan 25, 2016
Messages
19
So in cell A1 have the following formula:

A1 =SUM(AE10:AP10)-O10, which returns 0. O10 is yearly revenue, cells AE to AP are monthly revenues, which are calculated on the basis of $O$10/12, so it's normal that I get 0 in A1. I double-check by doing B1 = A1 = 0, which gives me TRUE.

However, when I do A1 =(SUM(AE10:AP10)-O10) [so with brackets], suddenly B1 = A1 = 0 gives me FALSE. Any idea why that might happen?

Thanks!
EG
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Can you post the data you have in AE10:AP10 and in O10 so we may reproduce the scenario. I tried it with some numbers on a sheet and it came back with true with both combinations, so something is out of joint.

Questions: do you know that sum of AE10:AP10 - O10 is exactly zero and not a small number close to zero but not zero?

cheers,

Angel
 
Upvote 0
Can you post the data you have in AE10:AP10 and in O10 so we may reproduce the scenario. I tried it with some numbers on a sheet and it came back with true with both combinations, so something is out of joint.

Questions: do you know that sum of AE10:AP10 - O10 is exactly zero and not a small number close to zero but not zero?

cheers,

Angel

Thanks Angel. Funny thing is that I only have that problem with one of the years. Other years (and their respective months) work just fine with and without brackets. O10 = £ 4,093,633, and the monthly cells are just $O$10/12. Everything is the same between different years, in terms of formatting, calculations, etc. But for some reason brackets mess things up for this particular year.
 
Upvote 0
So in cell A1 have the following formula:

A1 =SUM(AE10:AP10)-O10, which returns 0. O10 is yearly revenue, cells AE to AP are monthly revenues, which are calculated on the basis of $O$10/12, so it's normal that I get 0 in A1. I double-check by doing B1 = A1 = 0, which gives me TRUE.

However, when I do A1 =(SUM(AE10:AP10)-O10) [so with brackets], suddenly B1 = A1 = 0 gives me FALSE. Any idea why that might happen?

Thanks!
EG

By the way, I've also asked the above question here: (A - B) is not equal to A - B, apparently
 
Upvote 0
A1 =SUM(AE10:AP10)-O10, which returns 0. O10 is yearly revenue, cells AE to AP are monthly revenues, which are calculated on the basis of $O$10/12, so it's normal that I get 0 in A1. I double-check by doing B1 = A1 = 0, which gives me TRUE. However, when I do A1 =(SUM(AE10:AP10)-O10) [so with brackets], suddenly B1 = A1 = 0 gives me FALSE. Any idea why that might happen?

Yes. This is a side-effect of the dubious heuristic that is poorly described under the misleading title "Example When a Value Reaches Zero" at http://support.microsoft.com/kb/78113.

In a nutshell, when two values are deemed to be "close enough", Excel arbitrarily replaces the actual arithmetic result of their subtraction with exactly zero.

However, this heuristic applies only if the last operation is subtraction (or addition of values with opposite signs), and even then it is applied inconsistently. Simply putting parentheses around the entire expresses defeats the heuristic. So does simply adding or subtracting zero.

The remedy is: whenever an arithmetic expression is expected to be accurate to some degree of precision, explicitly round the expression to that number of decimal places.

For example, for most currency calculations, =ROUND(SUM(AE10:AP10)-O10,2).

PS.... You could have written =SUM(AE10:AP10,-O10) to get consistent results. However, that would not be exactly zero with the specific set of values that led to your original posting.
 
Last edited:
Upvote 0
A1 =SUM(AE10:AP10)-O10, which returns 0. O10 is yearly revenue, cells AE to AP are monthly revenues, which are calculated on the basis of $O$10/12, so it's normal that I get 0 in A1. I double-check by doing B1 = A1 = 0, which gives me TRUE. However, when I do A1 =(SUM(AE10:AP10)-O10) [so with brackets], suddenly B1 = A1 = 0 gives me FALSE. Any idea why that might happen?

I think my previous response answers your primary question, which I believe is: why does simply surrounding an expression with parentheses changes the result?

But I see some nuances in your description that might not have been addressed.

-----

First, do you really type B1=A1=0, or did you mean B1-A1=0? The difference is "B1 equals A1" v. "B1 minus A1".

We expect the first form to be FALSE because B1=A1 results in TRUE or FALSE, and the expressions TRUE=0 and FALSE=0 both return FALSE, even though TRUE and FALSE can be converted to 1 and 0.

Moreover, even if you change the first form to B1=A1=FALSE, we expect that to be FALSE when B1 equals A1. You never tell us the value of B1; presumably zero. In that case, B1=A1=FALSE is FALSE when A1 is exactly zero(!).

-----

Second, with the Excel screwy "close enough" heuristic, it is possible that =B1-A1 results in exactly zero, but =B1=A1 results FALSE, and vice versa.

In all such cases, =B1-A1-0 and =(B1-A1) consistently result an infinitesimal non-zero value (e.g. 1.23E-15) and =B1-A1=0 results in FALSE.

The reason is: Excel uses slightly different criteria for determining that B1 and A1 are "close enough" for B1-A1 to be considered zero and for B1=A1 to be considered TRUE.

B1=A1 is considered TRUE when they appear to be the same when formatted to 15 significant digits, even if their actual values are not exactly the same.

In contrast, B1-A1 (in some contexts) is considered exactly zero when the difference is below some threshold relative to their magnitudes. This is very technical; I am trying to simplify. The point is: it is not based on their appearance when formatted to 15 significant digits.

These infinitesimal differences arise because Excel uses the industry standard 64-bit binary floating-point to represent numbers internally. And that is not limited to 15 significant digits, an oft-repeated misconception even in Microsoft documentation like the aforementioned KB 78113.

However, Excel does limit formatting to 15 significant digits arbitrarily. Consequently, often we cannot see the infinitesimal differences.

For example, 0.1 appears to be 0.100000000000000 no matter how many decimal places we format. But in fact, it is exactly 0.100000000000000,0055511151231257827021181583404541015625.

(I use period for the decimal point and comma to demarcate the first 15 significant digits.)

-----

Finally, because of the binary approximation, it is not unusual for $O$10/12 added 12 times to be infinitesimally different from O10.

You might see the difference if you temporarily format =SUM(AE10:AP10) to display 15 significant digits.

But as noted above, often we do not see the infinitesimal difference even then.

The following would display the infinitesimal difference, if any:

=SUM(AE10:AP10)-TEXT(SUM(AE10:AP10),"0.00000000000000E+0")-0

formatted as Scientific. That is 14 zeros after "0.".

Note that that shows any infinitesimal difference in the internal binary representations. It does not show the difference between the decimal and binary representations; for example, 0.1 v. 0.100000000000000,0055511151231257827021181583404541015625.
 
Last edited:
Upvote 0
I think my previous response answers your primary question, which I believe is: why does simply surrounding an expression with parentheses changes the result?

But I see some nuances in your description that might not have been addressed.

-----

First, do you really type B1=A1=0, or did you mean B1-A1=0? The difference is "B1 equals A1" v. "B1 minus A1".

We expect the first form to be FALSE because B1=A1 results in TRUE or FALSE, and the expressions TRUE=0 and FALSE=0 both return FALSE, even though TRUE and FALSE can be converted to 1 and 0.

Moreover, even if you change the first form to B1=A1=FALSE, we expect that to be FALSE when B1 equals A1. You never tell us the value of B1; presumably zero. In that case, B1=A1=FALSE is FALSE when A1 is exactly zero(!).

-----

Second, with the Excel screwy "close enough" heuristic, it is possible that =B1-A1 results in exactly zero, but =B1=A1 results FALSE, and vice versa.

In all such cases, =B1-A1-0 and =(B1-A1) consistently result an infinitesimal non-zero value (e.g. 1.23E-15) and =B1-A1=0 results in FALSE.

The reason is: Excel uses slightly different criteria for determining that B1 and A1 are "close enough" for B1-A1 to be considered zero and for B1=A1 to be considered TRUE.

B1=A1 is considered TRUE when they appear to be the same when formatted to 15 significant digits, even if their actual values are not exactly the same.

In contrast, B1-A1 (in some contexts) is considered exactly zero when the difference is below some threshold relative to their magnitudes. This is very technical; I am trying to simplify. The point is: it is not based on their appearance when formatted to 15 significant digits.

These infinitesimal differences arise because Excel uses the industry standard 64-bit binary floating-point to represent numbers internally. And that is not limited to 15 significant digits, an oft-repeated misconception even in Microsoft documentation like the aforementioned KB 78113.

However, Excel does limit formatting to 15 significant digits arbitrarily. Consequently, often we cannot see the infinitesimal differences.

For example, 0.1 appears to be 0.100000000000000 no matter how many decimal places we format. But in fact, it is exactly 0.100000000000000,0055511151231257827021181583404541015625.

(I use period for the decimal point and comma to demarcate the first 15 significant digits.)

-----

Finally, because of the binary approximation, it is not unusual for $O$10/12 added 12 times to be infinitesimally different from O10.

You might see the difference if you temporarily format =SUM(AE10:AP10) to display 15 significant digits.

But as noted above, often we do not see the infinitesimal difference even then.

The following would display the infinitesimal difference, if any:

=SUM(AE10:AP10)-TEXT(SUM(AE10:AP10),"0.00000000000000E+0")-0

formatted as Scientific. That is 14 zeros after "0.".

Note that that shows any infinitesimal difference in the internal binary representations. It does not show the difference between the decimal and binary representations; for example, 0.1 v. 0.100000000000000,0055511151231257827021181583404541015625.

Thank you for your lengthy explanation, joeu2004, it makes things perfectly clear. By B1 = A1 = 0 I meant I put in B1 the formula =A1=0. I guess I'll have to with ROUND() function. What I find surprising is that the impact of the parentheses is so random. I have years 2016, 2017 and 2018, and only 2017 is affected by it. Even if I change the 2017 total year value in O10 (or hardcode it), there's still a difference between using parentheses and not using them. So apparently whatever O10 says is not relevant. Since monthly calculations and formatting are the same for all years, Excel seems to just have randomly (and stubbornly) decided to affect a particular cell in the whole sheet. Beats me..
 
Upvote 0
By B1 = A1 = 0 I meant I put in B1 the formula =A1=0.

Of course! Klunk! I should have thought of that reasonable interpretation.

What I find surprising is that the impact of the parentheses is so random. I have years 2016, 2017 and 2018, and only 2017 is affected by it. Even if I change the 2017 total year value in O10 (or hardcode it), there's still a difference between using parentheses and not using them. So apparently whatever O10 says is not relevant. Since monthly calculations and formatting are the same for all years, Excel seems to just have randomly (and stubbornly) decided to affect a particular cell in the whole sheet. Beats me..

Obviously, it's not specific to the particular cell. I don't think you meant that literally.

And the value in O10 is indeed relevant; in fact, it is the key.

Moreover, it is not so much that the impact of parentheses is unpredictable, but that the result of 64-bit binary floating-point arithmetic is unpredictable to some infinitesimal degree.

More to the point: the dubious Excel heuristic that replaces actual infinitesimal differences with exactly zero arbitrarily lulls us into a false sense of security with binary arithmetic.

Since the heuristic is implemented inconsistently, we treat surprises like your results with parentheses as unusual when, in fact, they are the norm(!).

I could explain better if you uploaded an example Excel file that demonstrates the problem to a file-sharing website, then posted the share/public URL in a response here. Of course, the file should be redacted of any personal identification data.

Note: This forum's moderators do not like us to do that. But often, the devil is in details that we cannot see in a table of formulas and values.

But perhaps the following explanation will be sufficient.

-----

You indicated that AE10 through AP10 are calculated "on the basis of" $O$10/12. Presumably, they are not simply =$O$10/12. But suppose they were.

For about 50% of the values between 12 and 124,800 in O10, =SUM(AE10:AP10)-O10-0 is not exactly zero. For example, 1367, 12,346 and 123,457.

The "redundant" -0 defeats the Excel "close enough" heuristic, resulting in the actual arithmetic result just like parentheses do.

Presumably, that is why you did not have problems with other rows representing years 2016 and 2018: by coincidence, their value in column O is among the other 50% for which =SUM(AE10:AP10)-O10-0 is exactly zero. For example, 1234, 12,345 and 123,459 as well as any integer divisible by 12.

Yet for all of the values between 12 and 124,800 in O10, =SUM(AE10:AP10)-O10 (without the "redundant" -0) seems to be exactly zero, due to the dubious Excel "close enough" heuristic.
 
Upvote 0
Ha, interesting. I put a couple of random values in 2017's O column, and saw that it didn't change anything, assumed there was something wrong with 2017. Decided to just put in 12 for all three years (the monthly calculation is indeed just =$O$10/12), and this time around parentheses didn't matter. Then took 2017's original value and put it in 2016 and 2018, and it did "mess up" things for those years too. So I guess I'll have to stick with ROUND(). Thanks a lot for your time and explanations, joeu2004!
 
Upvote 0

Forum statistics

Threads
1,214,927
Messages
6,122,309
Members
449,080
Latest member
jmsotelo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top