Syntax:
hexPascalString = hex$(expr)
Description:
This function returns a string of hexadecimal digits which represent the integer value of expr
. The returned string will consist of either 2, 4 or 8 characters, depending on which of defstr byte
, defstr word
or defstr long
is currently in effect. Note that if the value of expr
is too large to fit in a hex string of the currently selected size, the string returned by hex$
will not represent the true value of expr
.
In FutureBasic, integers are stored in standard "2's-complement" format, and the values returned by hex$
reflect this storage scheme. You need to keep this in mind when interpreting the results of hex$
, especially when expr
is a negative number. For example: hex$(-3)
returns "FD
" when defstr byte
is in effect; "FFFD
" when defstr word
is in effect; and "FFFFFFFD
" when defstr long
is in effect.
Note:
To convert a string of hex digits into an integer, use the following technique:
intVar = val&("&H" + hexPascalString)
intVar
can be a (signed or unsigned) byte variable, short-integer variable or long-integer variable. Byte variables can handle a hexPascalString
up to 2 characters in length; short-integer variables can handle a hexPascalString
up to 4 characters in length; long-integer variables can handle a hexPascalString
up to 8 characters in length.
See Also:
oct$; bin$; DEFSTRBYTE/word/long; val&