I need to define a SmallInt
constant with a hexadecimal value. In some way like this:
const
a: SmallInt = $8000;
Of course, the $8000
value violates subrange bounds of SmallInt
. I know it and do it deliberately.
Actually, I need a bitwise transfer of this literal to 16-bit signed integer.
If it were a variable, I could use an absolute
keyword:
var
a_prototype: Word;
a: SmallInt absolute a_prototype;
begin
a_prototype := $8000;
but it should be a constant.
Use a cast
const
a = SmallInt($8000);
If you need a typed constant then it would be
const
a: SmallInt = SmallInt($8000);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With