QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The CVD function decodes an 8-byte STRING generated by MKD$ (or read from a file) to DOUBLE numeric values.

Syntax

result# = CVD(stringData$)

Description

Example(s)

Reading an 8-byte encoded string n$ from a file and obtaining the decoded DOUBLE value:


FIELD #1, 8 AS N$, 12 AS B$...
GET #1
Y# = CVD(N$) 

Explanation: Reads a field from file #1, and converts the first eight bytes (N$) into an double-precision number assigned to the variable Y#.

Showcases the reduced space to store an encoded number.


a# = 77000.24523213
PRINT "Value of a#:"; a#
b$ = MKD$(a#)
PRINT "Value of a# encoded using MKD$: "; b$
PRINT "The string above, decoded using CVD:"; CVD(b$)


Value of a#: 77000.24523213

Value of a# encoded using MKD$: ñåxýâ╠‗@

The string above, decoded using CVD: 77000.24523213

Since the representation of a double-precision number can use up to 15 ASCII characters (fifteen bytes), writing to a file using MKD$ conversion, and then reading back with the CVD conversion can save up to 7 bytes of storage space.

See Also