Functions
7-2
COBl
The CDBL(X) function changes the type
of
expression (X) into double precision
floating-point representation. In this format, calculations are accurate to
16
decimal
places, compared to an accuracy
of
7 decimal places in single precision floating-
point representation.
Many fractions (such as
1/3
and .1) cannot be precisely represented with either
single or double precision floating point, due to BASIC-80's internal numeric
representation.
CDBL(expression)
10
A#=1/3
208#=CDBL(1)/3
30
PRINT A#,B#
40
END
RUN
.333333343267441
Ok
CHR$
.333333333333333
The CHR$ function evaluates the expression to an integer and returns the equivalent
ASCII character. The expression must evaluate to an integer between 0 and 255.
CHR$
(expression)
In the program below, the CHR$(12) command generates a form feed in line 110.
110
PRINT CHR$(12)
120
PRINT
130
PRINT
"TABLE
2-5:
COMMONLY
USED
CONSTANTS"
140
PRINT
150
PRINT
A;8;C;D;E
CINT
The CINT(X) function rounds the expression into an integer value and returns that
value.
If
the expression
is
less than -32768
or
greater than + 32767 then overflow will
result.
NOTE: The FIX and INT functions also convert to integer Formats. FIX
truncates; INT truncates to
an
integer argument.
CINT(expression)
This program averages three numeric values and returns an integer result:
10
INPUT
A,B,C
20
PRINT
(CINT((A+
8+C)/3))
30
END
RUN
?
45,
24,77
49
BASIC-80