calculator icon indicating copy to clipboard operation
calculator copied to clipboard

Error in the result of an expression with parentheses

Open silvairsoares opened this issue 1 year ago • 6 comments

When doing a calculation with the following expression:

(5 + 15) - (10 * (5 -3))

The result "20" is being obtained.

The result of this calculation should be "0"

= (5 + 15) - (10 * (5 -3)) = (20) - (10 * (2)) = 20 - (20) = 0

Incorrect results in Windows calculator:

image image

Correct results in Microsoft Excel: image

Correct results on Android calculator: image

Device and Application Information

  • OS Build: 19045.3448
  • Architecture: 64 bits
  • Application Version: 11.2307.4.0
  • Region:
  • Dev Version Installed:

If possible, I would like to fix this. I'm just reporting this problem. I don't want to fix it.

silvairsoares avatar Sep 22 '23 17:09 silvairsoares

This is your friendly Microsoft Issue Bot. I've seen this issue come in and have gone to tell a human about it.

MicrosoftIssueBot avatar Sep 22 '23 18:09 MicrosoftIssueBot

image The equals signal was missing

pLinho avatar Sep 22 '23 22:09 pLinho

As warned by user @pLinho, I had not pressed the equal button. Because when I finished typing the expression, there was a result on the calculator's display, leading me to believe that this was the final result. In this case, as the Windows calculator is displaying the result "20" (apparently, only the first part of the expression (5 + 15)), it could mislead the user, by assuming that that is the result of the operation. For the expression in this example, the Android calculator does not display any results until the user presses the equals button. It seems to me to be a more appropriate behavior.

silvairsoares avatar Sep 25 '23 12:09 silvairsoares

It is not the "only the first part of the expression". It is the last "complete expression" (Complete expression is a term I made up. If you open a parentheses is it an expression. When you close that parentheses it is a complete expression.). So it shows 20 because of (10 * (5 - 3)) part (you could realize this if you changed the numbers to detect which part it is). If you don't put the last closing parentheses, it will show you 2, because the last complete expression is 5 - 3.

I don't see any issue with this behaviour. It helps you to realize a mistype in complicated commands.

Instead of this they could fix the behaviour of openning and closing parentheses. For example if you type (5 + 15) - (10 * (5 - 3)), it shows 20 because of the thing I said. Then if you open a parentheses it still shows 20 because it is the last complete expression. But if you close that empty parentheses, it puts that 20 there. I don't think this is useful.

I also know some bugs (real bugs, bugs that prevent intended behaviours to happen when the stars are aligned) but won't even bother to report them. The commit history and the number of open issues is the reason. It is obvious that they don't care enough.

J3ekir avatar Oct 17 '23 11:10 J3ekir

This behavior seems quite confusing, actually. Following the explanation from @j3ekir, it SHOULD show 0 given the "last complete expression" was the whole expression; it was not missing a parenthesis or the like - this is complete:

image

If it was just the result of the last closed parenthesis, that part should be highlighted to make it clear.

igorsantos07 avatar Jul 10 '24 20:07 igorsantos07

This behavior seems quite confusing, actually. Following the explanation from @J3ekir, it SHOULD show 0 given the "last complete expression" was the whole expression; it was not missing a parenthesis or the like - this is complete:

image

If it was just the result of the last closed parenthesis, that part should be highlighted to make it clear.

I agree with you, I maintain my opinion that this behavior is bad.

Since the last complete expression in this case is the entire expression "(5 + 15) - (10 * (5 -3))", it makes no sense to show the result of only one part of the expression (be it the first , intermediate or final). Why would this partial result be important?

This behavior has much more potential to mislead the user than to help him identify a possible typing error.

silvairsoares avatar Jul 11 '24 13:07 silvairsoares