https://bugs.kde.org/show_bug.cgi?id=473669
Bug ID: 473669 Summary: KRunner can give erroneous output when evaluating equations involving implicit mutiplication Classification: Plasma Product: krunner Version: 5.27.7 Platform: Ubuntu OS: Linux Status: REPORTED Severity: normal Priority: NOR Component: calculator Assignee: plasma-b...@kde.org Reporter: arraybo...@gmail.com CC: alexander.loh...@gmx.de, natalie_clar...@yahoo.de Target Milestone: --- SUMMARY KRunner's calculator fails to apply the order of operations properly when dealing with implicit multiplication. It appears to use libqalculate's default Adaptive parsing mode, which is able to apply implicit multiplication before applying any other operation (even if this violates PEMDAS). This probably comes in handy for expressions involving variables, like "5/2x" (where 2x is meant to be taken as it's own thing), but for expressions consisting solely of known values (like what KRunner's calculator probably usually handles), it can result in extremely odd output. For instance, 6/2(2+1) = 9 according to PEMDAS, but KRunner outputs a 1 as the implicit multiply of 2(2+1) gets done before the division. STEPS TO REPRODUCE 1. Open KRunner by pressing Alt+F2. 2. Type "=6/2(2+1)" OBSERVED RESULT 1 EXPECTED RESULT 9 SOFTWARE/OS VERSIONS Linux/KDE Plasma: Kubuntu 22.04 LTS (available in About System) KDE Plasma Version: 5.27.7 KDE Frameworks Version: 5.104.0 Qt Version: 5.15.3 ADDITIONAL INFORMATION I believe this can be fixed by using libqalculate's "conventional" parsing mode on all calculations. This should be as easy as adding one line of code into https://invent.kde.org/plasma/plasma-workspace/-/blob/master/runners/calculator/qalculate_engine.cpp in the QalculateEngine::evaluate function. -- You are receiving this mail because: You are watching all bug changes.