EasyManuals Logo

Tandy 1000 Basic Reference Manual

Default Icon
411 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #52 background imageLoading...
Page #52 background image
Chapter
51
Basic
Concepts
When converting
double
to
single precision,
BASIC rounds the
number
to
7
significant digits. For example:
A!
=
1.2345678901234567
BASIC stores as
1.234568
A!
=
1.3333333333333333
BASIC stores as
1.333333
When converting
single
to
double
precision,
BASIC
adds
trailing
zeroes
to
the right of the original value. If the original value has
an exact binary representation in single precision format, the re-
sulting value
is
accurate.
For
example:
A#
=
1.5
BASIC stores as
1.50000000000000
However, if a number does not have an exact binary representa-
tion, the conversion creates an erroneous value. For example:
A#
=
1.3
BASIC stores as
1.299999952316284
You should not use such conversions in your program because
most fractional numbers do not have exact binary representa-
tions. You can avoid this by forcing the constant
to
be double pre-
cision, such as:
A#
=
1.3#
or
A#
=
1.3D
which BASIC stores as
1.3.
If you must convert from single
to
double precision, the following
programs show a special technique.
Type and run the following program:
10
A!
=
1.3
20
A#
=
A!
30
PRINT
A#
BASIC prints
1.299999952316284
Now type and run this program:
10
A!
=
1.3
20
A#
=
VAL(STRS(A!))
30
PRINT
A#
BASIC prints
1.3.
Converting the single precision number
to
a
string before converting
it
to
a double precision value causes
BASIC
to
store the value accurately.
Note:
BASIC cannot automatically convert numeric
data
to
string data or vice versa. This results in a
“Type mismatch” error. Use the
VAL
and STR$ func-
tions
to
accomplish this kind
of
conversion.
50

Table of Contents

Other manuals for Tandy 1000

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Tandy 1000 and is the answer not in the manual?

Tandy 1000 Specifications

General IconGeneral
ProcessorIntel 8088
Processor Speed4.77 MHz
RAM128 KB (expandable to 640 KB)
Operating SystemMS-DOS 2.11
ManufacturerTandy Corporation
Release Year1984
StorageSingle or double 5.25" floppy disk drive (360 KB), optional hard drive
SoundTandy 3-voice sound
PortsParallel, Serial
GraphicsCGA (Color Graphics Adapter)
Graphics Modes320x200, 640x200

Related product manuals