Bug 376655

Summary: Operations on Modulus operator were causing other operators to be erroneous
Product: [Applications] kcalc Reporter: Looserof7 <looserof7>
Component: generalAssignee: Evan Teran <evan.teran>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 16.12.3
Sentry Crash Report:

Description Looserof7 2017-02-19 03:16:44 UTC
KDE Frameworks 5.31.0
Qt 5.8.0 (built against 5.8.0)
The xcb windowing system

[Input] uname -a
[Output] Linux looserof7 4.4.48-1-MANJARO #1 SMP PREEMPT Thu Feb 9 22:17:50 UTC 2017  x86_64 GNU/Linux

I have noticed that modulus operations weren't accurate,

7%3 = 0.21 (from krunner, considering that modulus operator gives percentage)

steps to reproduce:
open kcalc,
step-1: Now select any mode from settings drop-down menu.
step-2: Type in 13 % 2 and then press =, I get no answer.

step-1: select Numeral System mode.
step-2: type in 100 / 2  this equals 50
step-3: type in 13 % 2 this gives no answer,
step-4: click on AC (Clear all),
step-5: type in 100 / 2 (In my case this equals to 5,000)

repeat steps 3 and 4:
step-5: type in 100 * 2 (I don't get answer)

What I mean to say is using Modulus operator is leading other calculations to be erroneous.

Please fix this bug.
Thank you.
Comment 1 Evan Teran 2017-02-19 17:16:03 UTC
Ah, this is an understandable misunderstanding :-).

In kcalc, % is the "percent" operator, not mod! If you want the actual modulus operator, please use the "Mod" button found in both Scientific and Statistic mode (top row, just left of center).

For more information on the "percent" operator, please see the manual: https://docs.kde.org/trunk5/en/kdeutils/kcalc/percent.html
Comment 2 Looserof7 2017-02-20 14:41:53 UTC
I'm ain't changing this to unconfirmed,

But please reconsider my comment and read it thoroughly, I have already mentioned that Modulus operator gives percentage, My problem is it isn't giving any results when I type in 13 % 2 in kcalc, I don't get any answer, but I get result for same from krunner.
Comment 3 Evan Teran 2017-02-21 16:26:31 UTC
@Looserof7,

One aspect of your report was that "What I mean to say is using Modulus operator is leading other calculations to be erroneous."

While "%" is not the modulus operator in kcalc, it WAS in fact causing subsequent calculations to be wrong. A one line patch to resolve this has been approved, and should fix the next version of kcalc that is released.

Thanks for your report :-)
Comment 4 Christoph Feck 2017-02-21 19:42:29 UTC
Git commit 5338befe329357a65f5eb333f921f07ce25de1cd by Christoph Feck.
Committed on 21/02/2017 at 19:41.
Pushed by cfeck into branch 'Applications/16.12'.

Also reset percent mode when clearing state
FIXED-IN: 16.12.3

Differential Revision: https://phabricator.kde.org/D4698

M  +1    -0    kcalc_core.cpp

https://commits.kde.org/kcalc/5338befe329357a65f5eb333f921f07ce25de1cd