Bug 133720 - kcalc produces wrong DEC to HEX conversion in 64bit math.
Summary: kcalc produces wrong DEC to HEX conversion in 64bit math.
Status: RESOLVED FIXED
Alias: None
Product: kcalc
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Klaus Niederkrüger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-07 18:39 UTC by Gilboa Davara
Modified: 2007-01-03 11:30 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch made from svn for KDE-3.5.4 (967 bytes, patch)
2006-09-17 13:37 UTC, Klaus Niederkrüger
Details
Fix? (545 bytes, patch)
2006-12-06 10:51 UTC, Gilboa Davara
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gilboa Davara 2006-09-07 18:39:13 UTC
Version:           3.5.4-2.0 (KDE-RedHat RPMs) (using KDE KDE 3.5.4)
Installed from:    Fedora RPMs
Compiler:          gcc (GCC) 4.1.1 20060525 (Red Hat 4.1.1-1) 
OS:                Linux

Steps to reproduce:

1. Open kcalc in decimal mode.
2. 2 ^ 59 
3. Returns: 576460752303423488
4. Switch to hex:

Expected result:
0x800000000000000

Actual result:
0x1000000000000000

Just to verify:
5. Switch back to decimal.
6. Subtract 1.
7. Returns: 576460752303423487
8. Switch to hex.

Expected result:
0x7FFFFFFFFFFFFFF

Actual result:
0x1000000000000000

Decimal math seems to be OK.
Decimal to Hex conversion seems to be broken. (32bit only?)

FYI: FC5/x86_64

- Gilboa
Comment 1 Philip Rodrigues 2006-09-08 16:10:57 UTC
Steps 1-4 work fine here (32 bit system), but 5-8 give the wrong answer (0x7FFFFFFFFFFFFC0).
Comment 2 Klaus Niederkrüger 2006-09-17 13:08:16 UTC
I believe I have fixed this now in the cvs-trunk (both for KDE-3.5.5 and for KDE-4.0). Please test this, if you have time!

Thank you for reporting this bug!!!

Klaus
Comment 3 Gilboa Davara 2006-09-17 13:14:24 UTC
Klaus,

Can you attach a patch?
I'll add it to the kdebase RPM patch-list, rebuild and test the fix.

- Gilboa
Comment 4 Klaus Niederkrüger 2006-09-17 13:37:21 UTC
Created attachment 17806 [details]
Patch made from svn for KDE-3.5.4

I hope this helps.

Klaus
Comment 5 Klaus Niederkrüger 2006-09-19 11:47:16 UTC
Seems to be fixed.
Comment 6 Gilboa Davara 2006-09-19 13:00:33 UTC
No go.

I took the patch and applied it against 3.5.4
1. Open kcalc in decimal mode.
2. 2 ^ 59
3. Returns: 576460752303423488
4. Switch to hex: 

Expected result:
0x800000000000000

Actual result:
0x4000000000000000

5. Switched back to decimal.

Expected result:
576460752303423488

Actual result:
9223372036854775808

Any chance this fix requires 3.5.5?

- Gilboa
Comment 7 Gilboa Davara 2006-09-23 11:04:34 UTC
I tested Klaus' latest patch and the bug seems to have been resolved.
Thanks.

- Gilboa
Comment 8 Gilboa Davara 2006-09-23 11:05:13 UTC
Marking as resolved.
Comment 9 Gilboa Davara 2006-09-23 11:15:04 UTC
Spoke too soon.

I took the patch and applied it against 3.5.4
1. Open kcalc in decimal mode.
2. 2 ^ 59
3. Returns: 576460752303423488
4. Switch to hex, result: 0x800000000000000 (OK).
5. Switched back to decimal, substract 1.
6. Returns: 576460752303423487 (OK).
7. Switch back to hex:

Expected result:
0x7FFFFFFFFFFFFFFF

Actual result:
0x8000000000000000

- Gilboa
Comment 10 Josh Metzler 2006-11-10 03:06:30 UTC
This works fine for me in kcalc 3.5.5 from Debian
Comment 11 Gilboa Davara 2006-12-06 10:51:52 UTC
Created attachment 18813 [details]
Fix?

Klaus,

This patch seems to solve the problem.
It's based around your patch. (I just added the x86_64 ifdef)
As expected in 64bit sizeof(long long int) == sizeof(long). (Unless you're
using Windows...)

Thanks, and sorry for taking my sweet time testing your fix ;)

- Gilboa
Comment 12 Klaus Niederkrüger 2007-01-03 01:26:24 UTC
This bug seems to have been finally fixed.

Thanks Gilboa (and after your wish in your last email, I started to read things on wikipedia. I learned something new. Interesting.).

Klaus
Comment 13 Gilboa Davara 2007-01-03 11:30:56 UTC
Happy to help.

Thanks for the fix.