BASIC-80

Functions

cos

The COS function returns the cosine value of the specified expression. The input is given in radians. The calculation is performed in single precision.

COS(expression)

10INPUT A

20B = COS(A)

30PRINT B

40END

RUN

?5

.2836621

Ok

CSNG

The CSNG(X) function changes the type of expression into single-precision floating- point representation. In this format, calculations are accurate to seven decimal places, compared to an accuracy of sixteen decimal places in double precision floating-point representation.

Performing calculations in single precision is faster than in double precision but may not be as accurate.

CSNG(expression)

10 A# = 1.00/3.00

20PRINT CSNG (A#) 12, A#/2

RUN

.1666667 .1666666666666667

CVI

CVS

eve

The CVI, CVS, and CVD functions convert strings into numbers. CVI converts a two character string into an integer by simply moving the two characters into the in- ternal integer representation. CVS converts a four character string to single preci- sion, and CVD converts an eight character string into double precision in a similar fashion.

These functions are used to retrieve numeric values from a random file buffer field, and are the reverse of MKI$, MKS$, and MKD$.

CVx(string expression)

AO/o = 1

B!=2

C#=3

0$ = MKI$(AO/o) + MKS$(B!) + MKD$(C#) A% = CVI (0$)

B! = CVS (MIO$(O$, 3))

C# = CVO (MIO$(O$, 7)) PRINT A, B!, C#

1 2 3

7-3

Page 67
Image 67
Intel 9800758-02 manual Csng, Cvi Cvs, 10 A# = 1.00/3.00, AO/o =