Summary: | Inconsistent handling of Numerical Base conversion functions and syntax. | ||
---|---|---|---|
Product: | [Plasma] krunner | Reporter: | aTosser <atosser> |
Component: | calculator | Assignee: | Alexander Lohnau <alexander.lohnau> |
Status: | RESOLVED FIXED | ||
Severity: | minor | CC: | nate, plasma-bugs |
Priority: | NOR | ||
Version: | 5.24.1 | ||
Target Milestone: | --- | ||
Platform: | Gentoo Packages | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/plasma/plasma-workspace/commit/8ea36e077a80a39aa3fec2260f217548f054953d | Version Fixed In: | |
Sentry Crash Report: |
Description
aTosser
2022-02-19 10:48:50 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2222 Git commit 8ea36e077a80a39aa3fec2260f217548f054953d by Fushan Wen, on behalf of Max Ramanouski. Committed on 19/10/2022 at 14:27. Pushed by fusionfuture into branch 'master'. runners/calculator: Improve output base handling Reimplement krunner base conversion through libqalculate PrintOptions.base instead of parsing decimal output and converting it to hex. This approach allows for correct display of multiple solutions converted to different base, for example: `hex= x * x = 4` will output `x = 0x2 || x = -0x2`. Also, this makes it possible to easily implement more bases like bin, oct, time, roman, etc. To detect required base findPrefix function was implemented in QalculateEngine, this function checks are there any common bases like hex, oct, bin, roman, time, pi and if there is it sets PrintOptions.base to corresponding base, this common base mappings were taken from libqalculate/src/qalc.cc set_option function (lines from 747 to 776, libqalcualate commit d767c71). To handle non-common bases prefix base was implemented, examples: `base 42=64` results to `1M`, `base 2**16=123456789` results to `\1883\52501`. When findPrefix function encounters base keyword in prefix, it sets base to BASE_CUSTOM, then at QalculateEngine::evaluate if base is set to BASE_CUSTOM everything in prefix after base keyword is calculated and set as custom base for main calculation via CALCULATOR->setCustomOutputBase. M +15 -11 runners/calculator/calculatorrunner.cpp M +1 -1 runners/calculator/calculatorrunner.h M +77 -1 runners/calculator/qalculate_engine.cpp M +3 -1 runners/calculator/qalculate_engine.h https://invent.kde.org/plasma/plasma-workspace/commit/8ea36e077a80a39aa3fec2260f217548f054953d |