GNOME Bugzilla – Bug 701951
Using CRTL-Z may lead to calculation error
Last modified: 2013-08-03 05:11:16 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);
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.
Basically a dupe of bug 694863 (though it appears you may have misunderstood that one).
*** Bug 705300 has been marked as a duplicate of this bug. ***
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 ***