Xojo Math badly broken: 32bit problems in a 64bit environment

Thanks. So you got an upgrade to Compiler engineer, I assume. :laughing:

1 Like

Maybe you need to write an article in xdev about it, perhaps itā€™ll get fixed then?

This site ? https://thezaz.com/ I donā€™t see why that would break the rules. If I canā€™t link there, then I canā€™t also link to twitter or google :man_shrugging:

1 Like

Youā€™re a rocket scientist Christian!

3 Likes

Itā€™s not a fix, but the problem should be somewhat alleviated if you replace all your UInt32 with UInt64.

Yes please!

Until you reach beyond the upper boundary of Int64, then the problem comes back.

Thatā€™s why I wrote ā€œalleviates the problemā€. :wink:

Nowadays 2 or 4 billion are not large numbers anymore (Bill Gates has more money, the US deficit is a thousand times larger) so with 32 bit Maths you will run more and more often into overflow errors. Using 64 bit (even on 32 bit systems) pushes out the threshold by a considerable distance ā€¦

Ok sure iā€™ll let you do that, at no charge please. Since we have so many sockets and protocols using UInt8, Uint16, Uint32 etcā€¦ even Int32 etcā€¦

Iā€™t not funny if you donā€™t get what you expect in comparison results! You get what i mean right?
There is no such solution as search, and replace all in this.

2 Likes

@Paul_Lefebvre Was the fix applied to any other functions? I was going to check some more functions tomorrow, but that would be pointless if they are already fixed ā€¦

1 Like

No, just Mod and integer div.

1 Like

From the original post:

When I read that, my first thought was, what possible purpose could there be to use a mod operation with a floating point number?
Regardless of whether Xojo converts the values to Int32 or Int64, using a value that started life as a floating point number is fraught with danger, and would need some serious testing to make sure that it behaves as intended.

Well, I hope I made clear what the purpose was (especially with with 32 bit systems). Sometimes you have no choice as people (incl Xojo) chose Double for their properties (like TotalSeconds) instead of Int64 (I explain a bit more about the historical and technical reasons in a forthcoming xDev article).

Regardless of whether Xojo converts the values to Int32 or Int64, using a value that started life as a floating point number is fraught with danger, and would need some serious testing to make sure that it behaves as intended.

Not really. If you use Double as an Integer then you also have ways to ensure that it can only be input as an integer (eg masks for user input, some easy tests).

But it would be so much better if Xojo used and/or coerced to 64bit Integer where it was appropriate.

I saw in the release notes 2020r2 that xojo.math functions have been depreciated.

Is there a list of what functions and what their replacements (if any) are?

If you go to the docs for the individual Xojo.Math methods a red box at the top of the page will show you what the replacement is.

Thanks!

Itā€™s not the math functions that have been deprecated but the Xojo namespace. The math functions are now in the global namespace where they previously were, so you can just use e.g.

y = sin(x)

instead of

y = Xojo.sin(x)