hexPascalString = hex$(expr)
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 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
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 "
defstr byte is in effect; "
defstr word is in effect; and "
defstr long is in effect.
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.
oct$; bin$; DEFSTRBYTE/word/long; val&