Databases Reference
In-Depth Information
To assign hex constants &H8000 through &HFFFF to a LONG integer without turning on bits 16
through 32 (&HFFFF0000), you must change them to a type of LONG by appending an ampersand
(&) character as follows:
LongInt& = &H8000& ' Use &H8000& (or
+32768) instead of &H8000
LongInt& = &H8001& ' Use &H8001& (or
+32769) instead of &H8001
. . . . . .
LongInt& = &HFFFF& ' Use &HFFFF& (or
+65535) instead of &HFFFF
Appending “&” to the constant is not necessary for hex constants outside the range &H8000&
through &HFFFF&.
The LONG integer &HFFFF& hex is equal to 65,535 decimal. The short integer &HFFFF hex
is equal to
1 decimal (according to the signed, two's complement, integer format standard). A
1
in decimal notation is &HFFFFFFFF in hex LONG-integer notation.
The hexadecimal constants &H8000 through &HFFFF default to short integers &H8000%
through &HFFFF%, which represent the decimal numbers
1% in the two's comple-
ment, signed binary integer format. You must append an ampersand (&) character to the end of the
constant to make it a LONG integer, as follows: &H8000& through &HFFFF& (which represent
the decimal numbers 32,768 through 65,535).
The hexadecimal constants &HFFFF8000 to &HFFFFFFFF are LONG integers that represent
the decimal numbers
32,768% to
32,768& to
1& in the two's complement, signed binary integer format.
Note: Bit masking (manipulation) is normally NOT done with floating-point numbers because of
the nature of the floating-point format. Bit masking normally is useful only with integers.
C
E
1
ODE
XAMPLE
'a& is a variable, and b& will serve as a bit mask:
a& = &HFFFF0000 ' &HFFFF0000 is a constant of type LONG
b& = &HFFFF& ' ATTENTION: Assign &HFFFF& instead of &HFFFF
'This masks out bits 16 through 32, and keeps bits 1 through 15:
a& = a& AND b&
PRINT "a& AND b& = "; a&, HEX$(a&); " prints zero (all bits off)"
' Assigning b& to &HFFFF instead of &HFFFF& changes the result:
b& = &HFFFF
' Now, b& contains &HFFFFFFFF, or -1 (all bits on). ANDing with b&
' does not change a&:
a& = a& AND b&
PRINT "a& AND b& = "; a&, HEX$(a&); " prints -65536, hex FFFF0000"
C
E
2
ODE
XAMPLE
' The following assigns short constant &HFFFF (-1) to a LONG
' integer. &HFFFF is converted to &HFFFFFFFF; the decimal
Search WWH ::




Custom Search