Bug 328368 - KAlgebra remainder, function returning different result on Windows
Summary: KAlgebra remainder, function returning different result on Windows
Status: RESOLVED FIXED
Alias: None
Product: kalgebra
Classification: Applications
Component: general (show other bugs)
Version: 0.11
Platform: unspecified Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Aleix Pol
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-03 10:38 UTC by utf8snowman
Modified: 2013-12-14 11:35 UTC (History)
1 user (show)

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


Attachments
Dictionary (41.80 KB, image/png)
2013-12-03 10:38 UTC, utf8snowman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description utf8snowman 2013-12-03 10:38:34 UTC
Created attachment 83895 [details]
Dictionary

Both are on version 0.11.

On Kubuntu:
rem(2,5, 5) = 2

On Windows:
rem(2.5, 5) = 2.5
Comment 1 utf8snowman 2013-12-03 10:39:34 UTC
There are also dictionary preview inconsistencies for map, floor, union, ceiling - seems to be a sampling issue?
Comment 2 Aleix Pol 2013-12-04 02:16:42 UTC
Well spotted, will need to investigate!
Comment 3 Aleix Pol 2013-12-04 02:21:41 UTC
I created a code-in task out of this, in case you want to give it a try :)
Comment 4 Benjamin Kaiser 2013-12-13 13:21:11 UTC
I have just done a bit of hunting. and the really odd thing about the whole remainder situation, is that it seemed to be converting it to an integer on Linux and keeping it floated on Windows.

I took a look through the function calls, and KAlgebra calls Analitza. In turn Analitza runs the case in operations.cpp line 65. On line 67 it runs "oper->setValue(int(remainder(a, b)));". The pass through the int is what is making giving it the different functionality in Linux.

The next question is "why is it not effecting the windows version of KAlgebra", but I think the answer to that is because the Analitza version, or the KAlgebra version are not the latest when installed through the kde windows installer. I checked the KAlgebra about dialogue on windows and it says "Version 0.11 Using KDE Development Platform 4.10.2" and on Arch Linux "Version 0.11 Using KDE Development Platform 4.11.4".

So what changed since the old version? I think it has something to do with a change made on April 8th 2013 in git commit 3a7f33e23c84dd27c698f86ac78a27c42c06d93b . In the operations.cpp on line 64-66. Before this commit the format of the 'oper' was set to an integer, but the math was still done floating point. After the change the math was converted to an int before setting to the 'oper' value.

So what can be done?
Nothing I guess, if the functionality seen in the later Linux version is the 'expected' functionality, then just wait for it to roll into stable on windows. Otherwise this is a regression and it needs to be fixed.
Comment 5 Benjamin Kaiser 2013-12-13 13:32:41 UTC
I rolled back the analitza repo locally and compiled. Running calgebra I had the following output:
"./calgebra
>>> rem(2.5,5)
2.5 
>>> "
Wheras the latest version of calgebra runs as follows:
"calgebra 
>>> rem(2.5,5)
2 
>>> "

This shows that the change mentioned in the above comment is what is causing this behaviour between different versions of Analitza (and also why it is different on windows if my assumption about the old branch used on windows is true)
Comment 6 utf8snowman 2013-12-13 13:35:09 UTC
Nice hunting! I did some investigating earlier and I think it's that
commit too - there's really no way for it to return it otherwise if
it's casted to an integer.

On 12/14/13, Benjamin Kaiser <benjaminjkaiser@gmail.com> wrote:
> https://bugs.kde.org/show_bug.cgi?id=328368
>
> --- Comment #5 from Benjamin Kaiser <benjaminjkaiser@gmail.com> ---
> I rolled back the analitza repo locally and compiled. Running calgebra I
> had
> the following output:
> "./calgebra
>>>> rem(2.5,5)
> 2.5
>>>> "
> Wheras the latest version of calgebra runs as follows:
> "calgebra
>>>> rem(2.5,5)
> 2
>>>> "
>
> This shows that the change mentioned in the above comment is what is
> causing
> this behaviour between different versions of Analitza (and also why it is
> different on windows if my assumption about the old branch used on windows
> is
> true)
>
> --
> You are receiving this mail because:
> You reported the bug.
>
Comment 7 Aleix Pol 2013-12-14 11:35:42 UTC
Ok, so it's just that kde-windows version is too old... Nice work!!