Something funky about UInt32 comparisons

Hi Randy,

First, thank you for being such a long time user. Wow, MacAddict! That really takes me back.

You would know because your logic would fail. This occurs when comparing a Uint to constant or literal that has a value that is outside of the bounds of a signed integer. That’s a REALLY BIG number. You’d get a bug report, step through your code and find that your literal does not compare properly to your Uint at which point you’d likely ask on the forum or contact us.

This behavior is not a bug. It’s by design. Xojo has not always had unsigned integer but it has always had signed integers. Signed integers (like all integer types) have a certain size/bounds. It has been argued that we could make the compiler handle this on its own. That is true. It might break some code but my guess is not many considering the very specific situation one must be in to encounter this.

We have chosen not to change the behavior because there’s a simple solution for those that ever run into this which now has been documented. Basically, you use CType to make clear what type you wish the literal to be so that you’re making an apples to apples comparison.

It’s not a question of technical skills as the release notes will tell you. We have fixed many compiler bugs in the past several years since we had a dedicated compiler engineer and have made the transition from 32 to 64 bit for the compiler as well. We have the talent we need.

The issue here is bang for the buck. Changing this behavior would have cost and that cost is not worth implementing a feature that impacts such a small portion of our users. If an engineer is working on this feature, we aren’t fixing some bug or implementing some other feature. That’s all that this comes down to in the end.

I hope this makes things a bit more clear.

1 Like