QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Ryster on February 26, 2021, 02:00:30 pm

Title: Calculation error.
Post by: Ryster on February 26, 2021, 02:00:30 pm
Hello.
I have such a problem. Well, the output of code running on 32-bit is different from that of code running on 64-bit. At the same time, it calculates incorrectly in the 64-bit version, and correctly in the 32-bit version. Is there any advice for this, or does it have to be.
Regards - Ryster
Title: Re: Calculation error.
Post by: bplus on February 26, 2021, 02:07:44 pm
Hello.
I have such a problem. Well, the output of code running on 32-bit is different from that of code running on 64-bit. At the same time, it calculates incorrectly in the 64-bit version, and correctly in the 32-bit version. Is there any advice for this, or does it have to be.
Regards - Ryster

Say what the problem is, maybe it's been reported and there is a fix, maybe it needs to be fixed, maybe it's unfixable in near future.

So my advice is to please provide more details.
Title: Re: Calculation error.
Post by: SpriggsySpriggs on February 26, 2021, 02:16:44 pm
Please paste the code you are using so we can help debug
Title: Re: Calculation error.
Post by: Ryster on February 26, 2021, 02:18:55 pm
Perhaps this problem has already been raised. As I wrote. With the same input data, the result is different. Except that the 32-bit version counts correctly. I suspect a different rounding procedure inside the 64 bit compiler.
Title: Re: Calculation error.
Post by: SpriggsySpriggs on February 26, 2021, 02:19:39 pm
We can't help you if you don't give us more info.
Title: Re: Calculation error.
Post by: SMcNeill on February 26, 2021, 02:26:48 pm
My guess is it’s the difference in the floating point math used. 

Look at the code here, and see if it “corrects” the issue for you: https://qb64.freeforums.net/thread/134/change-floating-point-precision

Title: Re: Calculation error.
Post by: Ryster on February 26, 2021, 02:32:30 pm
Thanks to SMcNeill, it is just like you wrote.
Regards - Ryster
Title: Re: Calculation error.
Post by: SMcNeill on February 26, 2021, 02:34:57 pm
It’s the difference in 80-bit FPU math processing (32-bit machines) vs 64-bit SSE math processing (64-bit machines).  The code I provided should allow you to set what you need to get the results you’re looking for. 
Title: Re: Calculation error.
Post by: Ryster on February 26, 2021, 02:46:10 pm
In my free time I will test and inform.

Regards - Ryster
Title: Re: Calculation error.
Post by: Pete on February 26, 2021, 03:50:43 pm
Another stunning endorsement for string math!

Yep, it's going to be what Steve said. When we get to 128 bit encryption, it will probably be this problem all over again. That's why I like string math, with the exception it's bit of work to program.

Similar to this topic, I wonder what Ed's app he posted would do under this 32-bit 64-bit floating point difference?

Pete
Title: Re: Calculation error.
Post by: Ryster on February 26, 2021, 05:38:06 pm
Double precision successfully solved the problem. The calculation is now valid on the 64-bit version. This error appeared sporadically, therefore it was difficult to notice it. It only occurred with certain numerical values. For example, the calculations for 1990 are correct and 2021 are incorrect. Thanks for your willingness to help.
Regards - Ryster