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 319934 - % Operator should do Modulus, not Percentage.
% Operator should do Modulus, not Percentage.
Status: RESOLVED FIXED
Product: gnome-calculator
Classification: Core
Component: general
5.6.x
Other All
: Normal minor
: ---
Assigned To: Rich Burridge
Rich Burridge
Depends on:
Blocks:
 
 
Reported: 2005-10-27 01:11 UTC by bryan
Modified: 2005-10-27 16:57 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12


Attachments
Fix to get percent operator working in non-arithmetic operator precedence mode (again). (441 bytes, text/plain)
2005-10-27 16:57 UTC, Rich Burridge
Details

Description bryan 2005-10-27 01:11:24 UTC
The current behavior of the % button is to get the percentage of the two
arguments. Whats even more odd is that 4%9 and 9%4 get the same value, 0.36? So
it takes the lower number and divides it into the higher number? That makes no
sense at all.

The more common usage of the % symbol is for modulus. 9%4 should return 1 as it
is the integer remainder of 9/4.

-Google uses it as modulus:
http://www.google.com/search?hl=en&q=9%254&btnG=Google+Search
-Microsoft Windows calculator uses it as modulus
-Python uses it as modulus
-PHP and Perl use it as modulus
etc

I would suggest changing the behavior of the % button to modulus

Other information:
Comment 1 Rich Burridge 2005-10-27 16:56:32 UTC
See bug #135140 for details on why the percent operator is
the way it currently is. 

Nothing odd about 4%9 and 9%4 both giving the same answer.
9 percent of 4 is the same as 4 percent of 9.

As of the 5.7.X gcalctool series, there is also a Modulus
operator. You can download a tarball from:

 http://ftp.gnome.org/pub/GNOME/sources/gcalctool/5.7/

What I have discovered is that the percent operator was broken
when in non-arithmetic operator precedence mode. I've just
checked a fix for that into CVS HEAD. That fix will show up in
v5.7.9 (or later). I'll also attach the patch here for reference.

In short, I'm closing this out as FIXED (because I did change something).
If I hadn't found the fix, I would have closed it as NOTABUG.
Comment 2 Rich Burridge 2005-10-27 16:57:54 UTC
Created attachment 53956 [details]
Fix to get percent operator working in non-arithmetic operator precedence mode (again).