Bug 500784 - kcalc allows to input multiple decimal points
Summary: kcalc allows to input multiple decimal points
Status: CONFIRMED
Alias: None
Product: kcalc
Classification: Applications
Component: general (other bugs)
Version First Reported In: 24.12.2
Platform: macOS (DMG) macOS
: NOR normal
Target Milestone: ---
Assignee: Gabriel Barrantes
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-02-26 20:01 UTC by Imron
Modified: 2025-03-07 00: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 Imron 2025-02-26 20:01:17 UTC
SUMMARY

I found out that in kcalc the multiple decimal points are permissible, even though it is mathematically incorrect. It gives Syntax error when "123....1" is inputted, however with "123.1.1.1" does some calculations.  I went over the handbook for kcalc, however did not find any information behind this calculation.

STEPS TO REPRODUCE
1. Open kcalc
2. input 123.1.1.1 (makes the input equal to 1.231) + 123.1.1.1

OBSERVED RESULT

Does some calculations, producing 2.462

EXPECTED RESULT

It should output input or syntax error. 

SOFTWARE/OS VERSIONS
Windows: 
macOS: Sonoma 14.0
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: 
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 6.8.1

ADDITIONAL INFORMATION
Comment 1 Imron 2025-02-26 20:02:37 UTC
I am new to KDE, but if possible wanted to work on these. Would really appreciate some head start.
Comment 2 minelorderagon16 2025-02-26 21:18:12 UTC
(In reply to Imron from comment #0)
> SUMMARY
> 
> I found out that in kcalc the multiple decimal points are permissible, even
> though it is mathematically incorrect. It gives Syntax error when "123....1"
> is inputted, however with "123.1.1.1" does some calculations.  I went over
> the handbook for kcalc, however did not find any information behind this
> calculation.
> 
> STEPS TO REPRODUCE
> 1. Open kcalc
> 2. input 123.1.1.1 (makes the input equal to 1.231) + 123.1.1.1
> 
> OBSERVED RESULT
> 
> Does some calculations, producing 2.462
> 
> EXPECTED RESULT
> 
> It should output input or syntax error. 
> 
> SOFTWARE/OS VERSIONS
> Windows: 
> macOS: Sonoma 14.0
> (available in the Info Center app, or by running `kinfo` in a terminal
> window)
> Linux/KDE Plasma: 
> KDE Plasma Version: 
> KDE Frameworks Version: 
> Qt Version: 6.8.1
> 
> ADDITIONAL INFORMATION

Was able to replicate on my system. Will mark as confirmed. there are instructions for contributing to KDE on the website, under the "Get Involved" button in the top bar.
Comment 3 Imron 2025-02-26 21:25:28 UTC
Thank you. I will work on this bug.
Comment 4 minelorderagon16 2025-02-26 21:27:30 UTC
(In reply to Imron from comment #3)
> Thank you. I will work on this bug.

Godspeed
Comment 5 Gabriel Barrantes 2025-03-01 14:58:21 UTC
(In reply to Imron from comment #3)
> Thank you. I will work on this bug.

Hey, (maintainer here)
so, what is probably happening is that inputs of the form .d+  (d a digit) are actually valid (no leading zero is required), and the parser "accepts" two consecutive numbers just fine as long it can determine where one finish and the next starts, so probably 123.1.1.1 gets parsed as 123.1|0.1|0.1 and the calculator assumes a multiplication operation bewteen the numbers yielding 123.1*0.1*0.1

to fix this a change in the regex to parse must be introduced, not allowing the last character to be a decimal point (. or ,), open a MR if you want some guidance.

The parser has become kinda complex to handle all such cases and I think some rework is need it before this but this can be merged no problem as it is now.
Comment 6 Imron 2025-03-03 16:04:39 UTC
Hello, yes I see how this works now. I think on invent KDE there is already a commit about the multiple decimal insertion. Is it still actual for me to work on this or the change is already approved?
Comment 7 Gabriel Barrantes 2025-03-07 00:19:27 UTC
(In reply to Imron from comment #6)
> Hello, yes I see how this works now. I think on invent KDE there is already
> a commit about the multiple decimal insertion. Is it still actual for me to
> work on this or the change is already approved?

Hasn't, talk to the guy is working on it, see if he wants some help.