Mod gives negative remainders

Bug #184704 reported by Offtopic
4
Affects Status Importance Assigned to Milestone
GCalctool
Fix Released
Medium
gcalctool (Ubuntu)
Fix Released
Low
Greg Grossmeier

Bug Description

Binary package hint: gcalctool

By the mathematical definition of the division algorithm ( n = q.d + r ; 0 <= r < d ), the reminder of a division can never be a negative integer.

More information: http://en.wikipedia.org/wiki/Modular_arithmetic

ProblemType: Bug
Architecture: amd64
Date: Sun Jan 20 19:32:28 2008
DistroRelease: Ubuntu 7.10
ExecutablePath: /usr/bin/gcalctool
NonfreeKernelModules: fglrx
Package: gcalctool 5.20.2-0ubuntu1
PackageArchitecture: amd64
ProcCmdline: gcalctool
ProcCwd: /home/offtopic
ProcEnviron:
 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
 LANG=en_CA.UTF-8
 SHELL=/bin/bash
SourcePackage: gcalctool
Uname: Linux morrocoy 2.6.22-14-generic #1 SMP Tue Dec 18 05:28:27 UTC 2007 x86_64 GNU/Linux

Tags: apport-bug
Revision history for this message
Offtopic (usednick) wrote :
Revision history for this message
Greg Grossmeier (greg.grossmeier) wrote :

Can you please provide a specific set of steps to reproduce this problem? With a couple simple tries I couldn't reproduce it.

Thanks!

Changed in gcalctool:
status: New → Incomplete
Revision history for this message
Offtopic (usednick) wrote :

Use the Scientific mode (View -> Scientific ; Crtl+S)
Try to do any mod operation with a negative dividend and a positive divisor. (The Mod button is just beside the Acc. button)
Ex: -20 Mod 9 yields -2 on gcalctool, while by definition it should be 7.

Offtopic.

Revision history for this message
Greg Grossmeier (greg.grossmeier) wrote :
Changed in gcalctool:
status: Incomplete → Confirmed
Revision history for this message
Greg Grossmeier (greg.grossmeier) wrote :

Quote from upstream:

====
The one thing that might still be wrong is something like:

5 mod -4

gcalctool (with or without this patch) gives an answer 0f 1

qalculate gives and answer of -3. I'm not sure how it got it.

Needs to be investigated further.

Greg, could you please ask Offtopic what s/he thinks the
answer to this should be (and how they derived it)?

Thanks.
====

Changed in gcalctool:
importance: Undecided → Low
Revision history for this message
Greg Grossmeier (greg.grossmeier) wrote :

Offtopic,

Sorry, I relayed the question too quickly. The developer figured it out.

There is a patch for left-to-right precedence, but not arithmetic yet. But they are working on it as we speak.

Changed in gcalctool:
status: Confirmed → In Progress
assignee: nobody → greg.grossmeier
Changed in gcalctool:
status: Unknown → Confirmed
Revision history for this message
Greg Grossmeier (greg.grossmeier) wrote :

The developers have fixed this issue in their development version. Look for the changes in the next release of gcalctool.

Changed in gcalctool:
status: In Progress → Fix Committed
Changed in gcalctool:
status: Confirmed → Fix Released
Revision history for this message
Offtopic (usednick) wrote :

Thanks for your work and attention guys!

Regards,
Offtopic.

Revision history for this message
Christophe Sauthier (christophe.sauthier) wrote :

The fix is released in, at least the current hardy version (5.21.92)

Changed in gcalctool:
assignee: greg.grossmeier → nobody
status: Fix Committed → Fix Released
Revision history for this message
Christophe Sauthier (christophe.sauthier) wrote :

Reput the old assignee, that I remove unwillingly... sorry...

Changed in gcalctool:
assignee: nobody → greg.grossmeier
Changed in gcalctool:
importance: Unknown → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.