After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 701951 - Using CRTL-Z may lead to calculation error
Using CRTL-Z may lead to calculation error
Status: RESOLVED DUPLICATE of bug 694863
Product: gnome-calculator
Classification: Core
Component: general
3.8.x
Other Linux
: Normal normal
: ---
Assigned To: gcalctool maintainers
gcalctool maintainers
: 705300 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-06-10 17:32 UTC by rodrigorenie
Modified: 2013-08-03 05:11 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description rodrigorenie 2013-06-10 17:32:49 UTC
After gnome-calculator gives the result of two (or more) equations, using the CTRL-Z shortcut to return to the previous equation and change any parameter from it, gnome-calculator will give the wrong result.

Reproducing the problem:

1) Open gnome-calculator;
2) Get the result from the equation: "5 x 5" (result: 25)
3) Using the number from previous result, continue with another equation: "25*2" (result: 50)
4) Now, use CTRL-Z to return to the previous equation (25 * 2), and change it to "25 * 3" (the result SHOULD BE 75, but it's 150);
Comment 1 PioneerAxon 2013-06-17 18:22:36 UTC
rodrigorenie,
Thank you for your bug report. :)

I confirm the bug.

Actually it's not a calculation error.
What really happens is, Calculator replaces (internally) the bold part of equation with variable "ans" before calculation.
Now, as you've already calculated 25*2 (result 50), it have stored ans=50. And when you do ctrl+Z, which will replace the text with 25 * 2 (while the value of ans is still 50), then you replace the 2 with 3. This results in equation that looks like "25 x 3", while it's internally "ans x 3", which calculates to 150.

The sane solution would be to save the value of variable "ans" along with the state. And restore it along with equation.
Comment 2 Elliott Sales de Andrade 2013-07-26 04:19:31 UTC
Basically a dupe of bug 694863 (though it appears you may have misunderstood that one).
Comment 3 PioneerAxon 2013-08-03 05:05:13 UTC
*** Bug 705300 has been marked as a duplicate of this bug. ***
Comment 4 PioneerAxon 2013-08-03 05:11:16 UTC
Ellott Sales de Andare,

Thank you.
Yes, it is a duplicate of bug #694863.

*** This bug has been marked as a duplicate of bug 694863 ***