Functions

BASIC-80

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

30PRINT A#,B#

40END

RUN

.333333343267441.333333333333333 Ok

CHR$

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.

110PRINT CHR$(12)

120PRINT

130PRINT "TABLE 2-5: COMMONLY USED CONSTANTS"

140PRINT

150PRINT 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

20PRINT (CINT((A+ 8+C)/3))

30END

RUN

? 45, 24,77

49

7-2

Page 66
Image 66
Intel 9800758-02 manual Chr$, Cint, Functions