1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 10:30:36 +00:00
QB64-PE/internal/help/CVD.txt
SteveMcNeill 33adc04fc4 Add temp folder to repo. It's necessary as well!
Just more initial setting on... nothing much to see here.
2022-04-28 13:39:56 -04:00

52 lines
2 KiB
Plaintext

The [[CVD]] function decodes an 8-byte [[STRING]] generated by [[MKD$]] (or read from a file) to [[DOUBLE]] numeric values.
{{PageSyntax}}
: {{Parameter|result#}} = [[CVD]]({{Parameter|stringData$}})
{{PageDescription}}
* ''CV'' functions ([[CVD]], [[CVS]], [[CVI]], [[CVL]], [[CVDMBF]], [[CVSMBF]]) are used to convert values encoded by ''MK$'' functions ([[MKD$]], [[MKS$]], [[MKI$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]).
* Variables of numerical types are also encoded when [[PUT]] to a [[RANDOM]] or [[BINARY]]-access file.
* '''QB64''' has [[_CV]] and [[_MK$]] functions which can also deal with extended [[Data types|data types]].
* [[DOUBLE]] values can range up to 15 decimal point digits. Decimal point accuracy depends on whole value places taken.
{{PageExamples}}
''Example 1:'' Reading an 8-byte encoded string n$ from a file and obtaining the decoded [[DOUBLE]] value:
{{CodeStart}} '' ''
{{Cl|FIELD}} #1, 8 {{Cl|AS}} N$, 12 {{Cl|AS}} B$...
{{Cl|GET}} #1
Y# = {{Cl|CVD}}(N$) '' ''
{{CodeEnd}}
: ''Explanation:'' Reads a field from file #1, and converts the first eight bytes (N$) into an double-precision number assigned to the variable Y#.
''Example 2:'' Showcases the reduced space to store an encoded number.
{{CodeStart}}
a# = 77000.24523213
{{Cl|PRINT}} "Value of a#:"; a#
b$ = {{Cl|MKD$}}(a#)
{{Cl|PRINT}} "Value of a# encoded using MKD$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVD:"; {{Cl|CVD}}(b$)
{{CodeEnd}}
{{OutputStart}}
Value of a#: 77000.24523213
Value of a# encoded using MKD$: ñåxýâ╠‗@
The string above, decoded using CVD: 77000.24523213
{{OutputEnd}}
: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.
{{PageSeeAlso}}
{{PageSeeAlso}}
* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]
* [[CVI]], [[CVS]], [[CVL]], [[CVSMBF]], [[CVDMBF]]
* [[_CV]], [[_MK$]]
{{PageNavigation}}
<