Bug 497301

Summary: log10(n) is not recognized as a calculator function
Product: [Plasma] krunner Reporter: gluedrinker
Component: calculatorAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: minor CC: alexander.lohnau, john.kizer, natalie_clarius, nate
Priority: NOR    
Version First Reported In: 6.2.4   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description gluedrinker 2024-12-10 22:34:04 UTC
SUMMARY
log( [expression] ) in krunner gives the result of the natural log instead of base 10 log

STEPS TO REPRODUCE
1. enter any log expression into krunner

OBSERVED RESULT
this evaluates to that of the natural log

EXPECTED RESULT
log() should probably be base 10 log, "ln()" and "log()" being the same is probably a bit counterintuitive

SOFTWARE/OS VERSIONS
KDE Plasma Version: 6.2.4
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.1
Comment 1 John Kizer 2024-12-19 20:35:47 UTC
I can reproduce this on Plasma 6.2.4. For what it's worth, KCalc itself does interpret log() as base 10, so it appears to be something specific on the KRunner side?
Comment 2 John Kizer 2024-12-20 15:53:07 UTC
Well, this was bugging me and I wanted to see if there was something that would explain it...and as it turns out, KRunner actually uses Qalculate as its backend for the calculator function (https://userbase.kde.org/Plasma/Krunner#Calculator), Qalculate views log() as ambiguous without a specific base, and it defaults to e as the base. If you type log(10; 10) into KRunner, for example, you should get 1 as expected.

So, this is *kind of* intended behavior...however, I do think there's a bug here still, as the intended Qalculate Base-10 Logarithm function - log10() - doesn't seem to be recognized by KRunner, so I switched the title accordingly.

I'm saying that's the intended Base-10 log function based on the Qalculate manual (https://qalculate.github.io/manual/qalculate-definitions-functions.html#qalculate-definitions-functions-1-Exponents--Logarithms) and a comment left by a Qalculate contributor on this topic: "In Qalculate log() is primarily intended for logarithms with bases other than 10 or e" (https://github.com/Qalculate/libqalculate/pull/430)
Comment 3 Nate Graham 2025-01-06 19:39:07 UTC
Works as expected if you add an equals sign before it: "=log10(5)". This is sometimes needed when invoking Qalculate functions directly, which is a bit of a hidden feature.