I know it exists unsigned 32-bit postfix "UL" e.g. &H81234UL but Is there a kind of 16-bit "US" also ?
something like: &H8123US
Joshy
[missing feature] Is there a postfix for unsigned 16-bit hex values ?
-
- Posts: 8641
- Joined: May 28, 2005 3:28
- Contact:
[missing feature] Is there a postfix for unsigned 16-bit hex values ?
Last edited by D.J.Peters on Jun 15, 2025 1:08, edited 1 time in total.
-
- Posts: 8641
- Joined: May 28, 2005 3:28
- Contact:
Re: [missing feature] Is there a postfix for unsigned 16-bit hex values ?
Tag on US and smell the coffee?
Code: Select all
#cmdline "-w none"
#define US and 65535u
print &H81234UL
print &H81234ULUS
print cushort(&H81234UL)
print cast(ushort,&H81234UL)
sleep
Re: [missing feature] Is there a postfix for unsigned 16-bit hex values ?
What for ?
If you have
won't make any trouble. Perhaps if you assign a long value, it's cut to 16 bit. If you assign a short value to a long variable, the highbytes should be set to 0 automatically. You'd have to write into the memory directly to get "unwanted" results.
An to keep it safe, use
to turn a ULONG value into a USHORT. For signed numbers better use the CAST operator. Curiously, the difference between signed and unsigned integers is a bigger problem.
If you have
Code: Select all
DIM AS USHORT myval
myval=&H3B1
An to keep it safe, use
Code: Select all
myval=myval AND &HFFFF