Chapter
51
Basic
Concepts
#
declares a double precision variable. BASIC stores the
value of the variable as
a
double precision number.
S#,
AD#, and YTDTOTAL# are samples of variables de-
clared as double precision.
declares a string variable. The value
of
the variable must
be enclosed in double quotes. A$, WRD$, and CITY$ are
samples of variables declared
as
string variables.
Note:
Any variable name can represent 4 different
variables. For example, A5%, A5!, AS#, and A5$ are
all valid and distinct variable names.
$
0
Use the following BASIC statements:
DEFINT
DEFSNG
Defines specified variableh) as integer.
Defines specified variable(s) as single precision.
(Since BASIC initially classifies all variables
as
single precision, you need
to
use DEFSNG only if
one
of
the other
DEF
statements is used.)
Defines specified variableb) as double precision.
Defines specified variableb) as string.
DEFDBL
DEFSTR
Chapter 10 describes these BASIC statements fully.
Numeric Precision Conversion
Your program may ask BASIC to convert numeric data from one
precision to another. The following section describes this
procedure.
When converting
singleldouble precision
to
integers,
BASIC
rounds the fractional portion of the number, if any. For example:
A%
=
32766.7
A%
=
-123.4567
BASIC stores as 32767
BASIC stores as -123
When converting
integers
to
singleldouble precision,
BASIC ap-
pends
a
decimal point and zeroes to the right of the original
value. For example:
A#
=
32767
A!
=
-1234 BASIC stores as -1234.000
BASIC stores as 32767.00000000000
49