User`s manual
4-18
Data Conversion
Every number used during execution must be typed as either integer, single
precision or double precision. Often this typing involves converting a number
from one form to another. This may produce unexpected, confusing results -
unless you understand the rules governing such automatic typing and type
conversion.
Typing of Constants
Constants are the actual numbers (not the variable names) used by LEVEL
II BASIC during execution. They may appear in your program (as in X=1/3,
the right side of the equation) or they may be temporary (intermediate)
constants created during the evaluation of an expression. In any case, the
following rules determine how a constant is typed:
I.
If a constant contains 8 or more digits, or if D is used in the
exponent, that number is stored as double precision. Adding a #
declaration character also forces a constant to be stored as double
precision.
II.
If the number is not double-precision, and if it is outside the range
-32768 to +32767 or if it contains a decimal point, then the number
is stored as single-precision. If number is expressed in exponential
notation with E preceding the exponent, the number is single
precision.
III.
If neither I nor II is true of the constant, then it is stored as an
integer.
Example Program
10 PRINT 1.234567, 1.2345678
RUN
1.23457 1.2345678
READY
>_
The first constant contains 7 digits; so by Rules I and II, it becomes a
single-precision number. Single precision numbers are printed as 6 digits
with the least significant digit properly rounded. But the second constant
contains 8 digits, therefore by Rule I it becomes a double precision number,
stored internally as 1.2345678000000000. The number is printed out with all
eight significant digits showing, and all the trailing zeros suppressed.










