Bug 444994 - Calculator giving me wrong answers (PEMDAS)
Summary: Calculator giving me wrong answers (PEMDAS)
Status: RESOLVED UPSTREAM
Alias: None
Product: krunner
Classification: Plasma
Component: calculator (show other bugs)
Version: 5.23.2
Platform: Arch Linux Linux
: NOR grave
Target Milestone: ---
Assignee: Alexander Lohnau
URL: https://github.com/Qalculate/libqalcu...
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-05 04:34 UTC by Rui Guilherme
Modified: 2021-11-09 16:19 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rui Guilherme 2021-11-05 04:34:54 UTC
SUMMARY
Krunner is not able to handle PEMDAS correctly. 

STEPS TO REPRODUCE
1. Open Krunner
2. type **6/158(154+5)-10 **

OBSERVED RESULT
-9,999761165512300

EXPECTED RESULT
-3.96202531646

SOFTWARE/OS VERSIONS
Linux/KDE Plasma:  5.23.2
KDE Plasma Version:  5.23.2
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION

I'm going to use a simple expression:
2/1(2+1)
(2/1)*(2+1)
2*(2+1)
2*3
Answers: 6 (Correct)

but Krunner try it:
2/1(2+1)
2/(1*3)
2/3
Answers: 0,6666666666666667 (Wrong)
Comment 1 Nate Graham 2021-11-08 20:16:13 UTC
Do you have libqalculate installed?
Comment 2 Rui Guilherme 2021-11-09 00:43:32 UTC
(In reply to Nate Graham from comment #1)
> Do you have libqalculate installed?
Yup!

# pacman -Qn | grep libqalculate
libqalculate 3.21.0-1

I can't uninstall because plasma-workspace need that lib, if I try:

$ pacman -R libqalculate   
verificando dependências...
erro: falha ao preparar a transação (não foi possível satisfazer as dependências)
:: a remoção de libqalculate quebra a dependência "libqalculate" necessária por plasma-workspace.
Comment 3 Rui Guilherme 2021-11-09 01:44:51 UTC
I force uninstall:
$ pacman -Rdd libqalculate 

But... https://i.imgur.com/8fFsgAP.png  

The problem then is not with krunner, in that case, I can close the issue and open a new at https://github.com/qalculate/libqalculate?
Comment 4 Nate Graham 2021-11-09 03:24:48 UTC
Indeed! And you can put the URL of your libqalculate bug report in the URL field of this one.
Comment 5 Rui Guilherme 2021-11-09 04:44:04 UTC
Issue: https://github.com/Qalculate/libqalculate/issues/350
Comment 6 Rui Guilherme 2021-11-09 04:48:01 UTC
(In reply to Nate Graham from comment #4)
Comment 7 Rui Guilherme 2021-11-09 16:19:12 UTC
(In reply to Nate Graham from comment #4)
> Indeed! And you can put the URL of your libqalculate bug report in the URL
> field of this one.

You can see here: https://github.com/Qalculate/libqalculate/issues/350#issuecomment-963831275

For qalc '2/1 (2+1) = 6' and '2/1(2+1) = 0,666666667' are diferent expression and diferent result. 

Check here:
https://i.imgur.com/jdZ2n9n.png

Now, Krunner without space:
https://i.imgur.com/VI7XqAP.png

With space: 
https://i.imgur.com/mYKK4jB.png