03-22-2025, 03:42 PM
For an explanation of the issue you're seeing, (so you can account for it elsewhere in your code), see this:
Notice how the &H value changes on you? That's because QB64 and basic back in the day, didn't have UNSIGNED values, and also because they wanted to save as much precious memory as possible.
&HH was... an INTEGER, as there was no _BYTE type in QB45. Thus, it represented 255.
&HHHH was... an INTEGER, as integers are 2 bytes and that was the smallest size that could represent those hex digits. As an integer, that made its value -1.
&HHHHHHHH was... an LONG. 4 bytes to hold those 8 hex values. In a signed long, that also made the value -1.
So.... when you AND a value with -1, is that AND with a long or an integer or ????
You run into issues. (As you both have noticed.)
Solution?
Take that ambiguity out of your &H type.
IF &HFF is *supposed* to be a LONG, then mark it as one: &HFF&
IF &HFF is *supposed* to be an _INTEGER64, then mark it as one: &HFF&&
Those suffixes there on the end of that &H value is *essential* for what you're doing to work without issues for you. Else you're mixing integers with longs with int64s and... You get FEFOFLOPOP00PS
Code: (Select All)
Print Hex$(&HFFFFFFFF And &HFF)
Print Hex$(&HFFFFFFFF And &HFFFF)
Print Hex$(&HFFFFFFFF And &HFFFFFFFF)
Print
Print &HFF
Print &HFFFF
Print &HFFFFFFFF
Print
Print &HFF~%%
Print &HFFFF~%
Print &HFFFFFFFF~&
Notice how the &H value changes on you? That's because QB64 and basic back in the day, didn't have UNSIGNED values, and also because they wanted to save as much precious memory as possible.
&HH was... an INTEGER, as there was no _BYTE type in QB45. Thus, it represented 255.
&HHHH was... an INTEGER, as integers are 2 bytes and that was the smallest size that could represent those hex digits. As an integer, that made its value -1.
&HHHHHHHH was... an LONG. 4 bytes to hold those 8 hex values. In a signed long, that also made the value -1.
So.... when you AND a value with -1, is that AND with a long or an integer or ????
You run into issues. (As you both have noticed.)
Solution?
Take that ambiguity out of your &H type.
IF &HFF is *supposed* to be a LONG, then mark it as one: &HFF&
IF &HFF is *supposed* to be an _INTEGER64, then mark it as one: &HFF&&
Those suffixes there on the end of that &H value is *essential* for what you're doing to work without issues for you. Else you're mixing integers with longs with int64s and... You get FEFOFLOPOP00PS