Difference between revisions of "CVL"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
(Created page with ''''Purpose:''' To convert string values to numeric values. '''Syntax:''' CVL(''4-byte string'') '''Comments:''' * Numeric values read in from a random-access disk file must be …')
 
imported>Clippy
Line 29: Line 29:
:Reads a field from file #1, and converts the first four bytes (N$) into a long integer number assigned to the variable Y.
:Reads a field from file #1, and converts the first four bytes (N$) into a long integer number assigned to the variable Y.


:Since a long number can contain as many as seven ASCII characters (seven bytes), writing a file using [[MKS$]] conversion, and reading with the [[CVS]] conversion, as many as three bytes per number recorded are saved on the storage medium. Even more may be saved if double-precision numbers are required. [[MKD$]] and [[CVD]] conversions would be used in this case.
:Since a long number can contain as many as ten ASCII characters (ten bytes), writing a file using [[MKS$]] conversion, and reading with the [[CVS]] conversion, as many as six bytes per number recorded are saved on the storage medium. Even more may be saved if double-precision numbers are required. [[MKD$]] and [[CVD]] conversions would be used in this case.





Revision as of 02:40, 10 September 2009

Purpose: To convert string values to numeric values.

Syntax: CVL(4-byte string)

Comments:

  • Numeric values read in from a random-access disk file must be converted from strings back into numbers if they are to be arithmetically manipulated.
  • CVI converts a 2-byte string to an INTEGER number. MKI$ is its complement.
  • CVS converts a 4-byte string to a SINGLE-precision number. MKS$ is its complement.
  • CVL converts a 4 byte string to a LONG integer number. MKL$ is its compliment.
  • CVD converts an 8-byte string to a DOUBLE-precision number. MKD$ is its complement.



Examples:

FIELD #1, 4 AS N$, 12 AS B$...
GET #1
Y = CVL(N$)

Explanation:

Reads a field from file #1, and converts the first four bytes (N$) into a long integer number assigned to the variable Y.
Since a long number can contain as many as ten ASCII characters (ten bytes), writing a file using MKS$ conversion, and reading with the CVS conversion, as many as six bytes per number recorded are saved on the storage medium. Even more may be saved if double-precision numbers are required. MKD$ and CVD conversions would be used in this case.


See also: MKI$, MKS$, MKL$ and MKD$



Navigation:

Go to Keyword Reference - Alphabetical

Go to Keyword Reference - By usage