GNOME Bugzilla – Bug 157021
Gcalctool can't do ^(1/3) for negative numbers
Last modified: 2004-12-22 21:47:04 UTC
I typed the sequence: 27 (+/-) ^ 3 (1/x) = the Gcalctool then show ERROR To reproduce this on 5.5.0 I have to disable arithmetic precedence.
UPSTREAM http://bugzilla.gnome.org/show_bug.cgi?id=157021
Taking this back. I misread the description and thought the problem was with the new arithmetic precedence mode. The problem can be simply recreated with 27 +/- x^y 3 = Investigating...
Here's the stack trace for the error: t@1 (l@1) stopped in doerr at line 1214 in file "calctool.c" 1214 if (!v->started) { t@1 l@1 <3> where current thread: t@1 =>[1] doerr(errmes = 0x75ae8 "Error"), line 1214 in "calctool.c" [2] mperr(), line 1966 in "mp.c" [3] mppwr2(x = 0xa0188, y = 0x9df10, z = 0xa0188), line 3365 in "mp.c" [4] do_calc(), line 476 in "functions.c" [5] process_item(button = 0x8c610), line 560 in "display.c" [6] button_proc(widget = 0x258d38, user_data = 0x1a), line 618 in "gtk.c" ...
The problem is that the mppwr2() routine specifically checks that for x^y, x is not a negative number.
Changes have been added to fix this for non-arithmetic precedence mode. for x ^ y, if x is negative and y is an integer, then the mppwr() MP routine is used instead of mppwr2(). Added a new calc_xpowy() routine in mpmath.c to do this calculation. Also added a show_error() routine to functions.c to display the error in the status bar if the user enters -X with non-integer Y. Sami will be adding a similar change for arithmetic operator precdedence mode, and after that we can close out this bug.
Sami has checked in the other part of the fix. I've bumped the version number in configure.in to 5.5.10, but I'm not going to generate a new tarball to nearer the time of the next GNOME 2.9 "call for tarballs".