@bplus I've finally wrapped my head around what exactly is going on to cause the issue you posted on.
First, let's take a look at the core of the problem:
Print 4294967295, "literal"
Now here, we specify that foo should be an unsigned long, and it's value should be the equivalent of a -1. We'd expect to see a value of &HFFFFFFFF, overflowed to become 4294967295 for us, and the PRINT statement confirms this value for us.
Unfortunately, the IF statement doesn't think the two numbers match at all!
WHY??
Because QB64 only stores CONST values as one of 4 actual types: String, Float, Signed Integer64, Unsigned Integer64.
Sure, we specified that we wanted to store the value as an unsigned value, but CONST only has unsigned integer64's which it stores the numbers as, so that -1 ends up becoming &HFFFFFFFFFFFFFFFF rather than &HFFFFFFFF -- as illustrated below:
Print 4294967295, "literal"
UInt64_Max = -1
There's no point in specifying CONSTs as byte, integer, or longs. They'll all simply be integer64s.
The only really interesting and odd thing about these CONST values -- we set a flag to try and keep track of what type they're supposed to be, and PRINT and HEX$ and a few other places make use of that flag to give us the results we expect to see... It's just that IF and DO and WHILE and such don't bother with that flag, so they don't convert that value.
PRINT foo will print the desired unsigned long value, as it uses that (uint32) flag.
IF foo doesn't use that flag, so it uses the internal unsigned integer64 value...
And that's the basic crux of the issue at hand here.
CONST skyC~& = &HFF8B8888 <-- &H math gives us a negative value for this.
skyC~& is an unsigned integer64 internally, with a flag which is supposed to track its type.
PRINT will use that flag and print the expected type value.
IF doesn't use that flag and thus the 64-bit number doesn't match the expected 32-bit equivalent.
The code I posted above should fix the issue as far as CONST is concerned, but with &H changing from integer to long to integer64 as it wishes, it's a situation where you could run into just about anywhere.
My suggestion from now on: If you use &H, specify the return type manually yourself. Instead of &HFF8B8888, make it &HFF8B8888~&. This will force that return value to be an unsigned long, rather than a signed long, and that'd stop the issue before it ever started. ;)