Page 18 of 62
SBasic User's Manual SBasic Version 2.7 Page 18
Printed: December 5, 1999
Numeric constants
SBasic supports decimal, hexadecimal, and binary numeric constants.
To enter a hexadecimal number in an SB file, preface the number with a
'$'. To enter a binary number in an SB file, preface the number with
a '%'.
Hexadecimal numbers may contain the characters 0-9, A-F, and a-f.
Binary numbers may contain the characters 0 and 1.
The following examples show how to enter different numeric constants:
foo = 1234 ' assigns decimal 1234 to FOO
bar = $1234 ' assigns hexadecimal $1234 to BAR
alpha = %10000 ' assigns decimal 16 to alpha
cat = $12 + 34 ' adds hex $12 to decimal 34
SBasic also supports ASCII character constants. To enter an ASCII
constant, enclose the character in single-quotes. The value used will
consist of the binary equivalent of the quoted character. An ASCII
constant always consists of eight bits; the upper eight bits of the
variable involved will always be 0.
For example:
foo = 'a' ' assigns lowercase-A (97) to foo