Bug 488728 - Input error when entering hexadecimal number
Summary: Input error when entering hexadecimal number
Status: RESOLVED FIXED
Alias: None
Product: kcalc
Classification: Applications
Component: general (show other bugs)
Version: 24.05.1
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Gabriel Barrantes
URL:
Keywords:
: 485319 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-06-19 11:03 UTC by Gernot Gebhard
Modified: 2024-09-12 18:51 UTC (History)
2 users (show)

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


Attachments
Screenshot showing the input error (39.92 KB, image/png)
2024-06-19 11:03 UTC, Gernot Gebhard
Details
Screenshot showing input error for fffff (66.92 KB, image/png)
2024-09-06 07:16 UTC, Gernot Gebhard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gernot Gebhard 2024-06-19 11:03:16 UTC
Created attachment 170633 [details]
Screenshot showing the input error

SUMMARY
KCalc does not seem to accept (some) hexadecimal numbers.


STEPS TO REPRODUCE
1. Enable "Numeral System Mode"
2. Switch to "Hex" mode
3. Paste "0x400095f0" into the line edit
4. Hit enter

OBSERVED RESULT
Input error

EXPECTED RESULT
0x400095f0

ADDITIONAL INFORMATION
The same happens for "400095f0" and other hexadecimal numbers.
Comment 1 popov895 2024-06-19 12:26:07 UTC
*** Bug 485319 has been marked as a duplicate of this bug. ***
Comment 2 Deriabin Sergei 2024-06-19 14:05:26 UTC
(In reply to popov895 from comment #1)
> *** Bug 485319 has been marked as a duplicate of this bug. ***
Some more test cases for version  24.05.1:
ab -- Input error
AB -- AB
00AB -- 0
00ab -- Input error
0x00AB -- AB
0x00ab -- Input error
Comment 3 Gabriel Barrantes 2024-06-21 00:00:58 UTC
(In reply to Deriabin Sergei from comment #2)
> (In reply to popov895 from comment #1)
> > *** Bug 485319 has been marked as a duplicate of this bug. ***
> Some more test cases for version  24.05.1:
> ab -- Input error
> AB -- AB
> 00AB -- 0
> 00ab -- Input error
> 0x00AB -- AB
> 0x00ab -- Input error

This happens because we miss to add support for lowercase hex numbers, we will add it soon...
00AB yields an invalid result due to being interpreted as an octal(0)*hex(AB), those cases would be also address in an upcoming patch.
Comment 4 Bug Janitor Service 2024-06-29 22:35:05 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kcalc/-/merge_requests/112
Comment 5 Gabriel Barrantes 2024-06-29 22:36:32 UTC
Git commit a3899070820aa5166d76767a05dd16fd62c9a006 by Gabriel Barrantes.
Committed on 29/06/2024 at 22:20.
Pushed by gabrielbarrantes into branch 'master'.

GIT_SILENT Add support for lowercase hex knumbers

Add support for lowercase hex numbers in the knumber library. Also,
add some miscellaneous tests.

M  +1    -1    knumber/knumber.cpp
M  +16   -0    knumber/tests/knumbertest.cpp

https://invent.kde.org/utilities/kcalc/-/commit/a3899070820aa5166d76767a05dd16fd62c9a006
Comment 6 Bug Janitor Service 2024-07-05 16:45:11 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kcalc/-/merge_requests/115
Comment 7 Gabriel Barrantes 2024-07-05 17:03:30 UTC
Git commit f92b33201fc02248f46b4762f49dc1544a24f60a by Gabriel Barrantes.
Committed on 05/07/2024 at 17:02.
Pushed by gabrielbarrantes into branch 'master'.

Add parsing support for lower case hex numbers

M  +9    -0    autotests/kcalc_parser_core_test.cpp
M  +37   -13   kcalc_parser.cpp
M  +11   -0    kcalc_parser.h

https://invent.kde.org/utilities/kcalc/-/commit/f92b33201fc02248f46b4762f49dc1544a24f60a
Comment 8 Bug Janitor Service 2024-07-06 21:43:33 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kcalc/-/merge_requests/117
Comment 9 Gabriel Barrantes 2024-07-19 19:52:34 UTC
Git commit 03d25ed2d731a3e0266395d20bd01d01fd41a2c0 by Gabriel Barrantes.
Committed on 19/07/2024 at 19:48.
Pushed by gabrielbarrantes into branch 'master'.

Change octal prefix from "0" to "0o"

Leading 0s will be ignored in all bases for all numeric inputs.
Related: bug 487837

M  +12   -4    autotests/kcalc_parser_core_test.cpp
M  +1    -1    kcalc_display.cpp
M  +8    -4    kcalc_parser.cpp
M  +2    -1    kcalc_parser.h

https://invent.kde.org/utilities/kcalc/-/commit/03d25ed2d731a3e0266395d20bd01d01fd41a2c0
Comment 10 Gernot Gebhard 2024-09-02 08:00:44 UTC
Tried with KCalc - Version 24.08.0 and this seems to work fine now. Hence, VERIFIED.
Comment 11 Gernot Gebhard 2024-09-05 12:15:45 UTC
Mh, sorry to reopen but this seems not to work properly yet.
If you enter:

FFFFF

in the line edit and hit enter the input is accepted.
If you enter:

ffff

the input is rejected with "Input error".

Is it truly intended that lowercase hex is not supported?
Comment 12 Gabriel Barrantes 2024-09-05 13:18:54 UTC
(In reply to Gernot Gebhard from comment #11)
> Mh, sorry to reopen but this seems not to work properly yet.
> If you enter:
> 
> FFFFF
> 
> in the line edit and hit enter the input is accepted.
> If you enter:
> 
> ffff
> 
> the input is rejected with "Input error".
> 
> Is it truly intended that lowercase hex is not supported?

Try the lastest version , is already supported.
Comment 13 Gernot Gebhard 2024-09-06 07:16:45 UTC
Created attachment 173376 [details]
Screenshot showing input error for fffff

I tried this with 24.08.0 which appears to be the most recent version.
Did I overlook something?
Comment 14 Gabriel Barrantes 2024-09-06 15:35:55 UTC
(In reply to Gernot Gebhard from comment #13)
> Created attachment 173376 [details]
> Screenshot showing input error for fffff
> 
> I tried this with 24.08.0 which appears to be the most recent version.
> Did I overlook something?

You are right, I forgot about that case because it interferes with acos, cos and others...
it fails because the first character is lower case, let me fix it. Can you test it?
Comment 16 Gernot Gebhard 2024-09-10 07:42:50 UTC
(In reply to Gabriel Barrantes from comment #15)
> https://invent.kde.org/utilities/kcalc/-/merge_requests/151

For that I'd need to build it right? Currently, I don't have the possibility to do that.
Comment 17 Gabriel Barrantes 2024-09-12 18:27:51 UTC
(In reply to Gernot Gebhard from comment #16)
> (In reply to Gabriel Barrantes from comment #15)
> > https://invent.kde.org/utilities/kcalc/-/merge_requests/151
> 
> For that I'd need to build it right? Currently, I don't have the possibility
> to do that.

ok, I will push it as a hot fix either way.
Comment 18 Gabriel Barrantes 2024-09-12 18:51:56 UTC
Git commit 17933a6ee0351591fb3325c7f7e76ee1daf88cbc by Gabriel Barrantes.
Committed on 12/09/2024 at 18:40.
Pushed by gabrielbarrantes into branch 'master'.

Support hex numbers that start with a letter (a-f)

When entering numbers like 'ce' some ambiguity arises because this
could be interpreted as 'light speed times euler's number' or as
'0xce'. To resolve this decide based on wheter the calculator is
in Numeral System mode or not.

M  +38   -0    autotests/kcalc_parser_core_test.cpp
M  +8    -0    kcalc.cpp
M  +23   -0    kcalc_parser.cpp
M  +6    -0    kcalc_parser.h

https://invent.kde.org/utilities/kcalc/-/commit/17933a6ee0351591fb3325c7f7e76ee1daf88cbc