CV: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE:_CV}} The _CV function is used to convert _MK$, ASCII, STRING values to numerical values. {{PageSyntax}} :{{Parameter|result}} = _CV({{Parameter|numericalType}}, {{Parameter|MKstringValue$}}) {{Parameters}} * {{Parameter|numericalType}} is any number type: INTEGER, LONG, SINGLE, DOUBLE, _INTEGER64, _FLOAT, _BYTE or _BIT. * Integer, Long, Byte and Bit values can be signed or _UNSIGNED. * The {{Para...")
 
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 7: Line 7:




{{Parameters}}
{{PageParameters}}
* {{Parameter|numericalType}} is any number type: [[INTEGER]], [[LONG]], [[SINGLE]], [[DOUBLE]], [[_INTEGER64]], [[_FLOAT]], [[_BYTE]] or [[_BIT]].
* {{Parameter|numericalType}} is any number type: [[INTEGER]], [[LONG]], [[SINGLE]], [[DOUBLE]], [[_INTEGER64]], [[_FLOAT]], [[_BYTE]] or [[_BIT]].
* Integer, Long, Byte and Bit values can be signed or [[_UNSIGNED]].
* Integer, Long, Byte and Bit values can be signed or [[_UNSIGNED]].
Line 14: Line 14:


{{PageDescription}}
{{PageDescription}}
* The {{Parameter|MKstringvalue$}} value type must match the numerical type parameter used.  
* The {{Parameter|MKstringvalue$}} value type must match the numerical type parameter used.
* [[_MK$]] [[STRING|string]] values consist of [[ASCII]] characters in the same byte length as the number value type.
* [[_MK$]] [[STRING|string]] values consist of [[ASCII]] characters in the same byte length as the number value type.


Line 20: Line 20:
{{PageExamples}}
{{PageExamples}}
''Example:'' Using the _MK$ and _CV functions:
''Example:'' Using the _MK$ and _CV functions:
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|DIM}} i64 {{Cl|AS}} {{Cl|_INTEGER64}}
{{Cl|DIM}} i64 {{Cl|AS}} {{Cl|_INTEGER64}}
{{Cl|DIM}} i64str {{Cl|AS}} {{Cl|STRING}}
{{Cl|DIM}} i64str {{Cl|AS}} {{Cl|STRING}}


i64 = 2 ^ 61
i64 = {{Text|4099318665700534580|#F580B1}}
i64str = {{Cl|_MK$}}({{Cl|_INTEGER64}}, i64)
i64str = {{Cl|_MK$}}({{Cl|_INTEGER64}}, i64)


{{Cl|PRINT}} "I64:"; i64
{{Cl|PRINT}} {{Text|<nowiki>"I64:"</nowiki>|#FFB100}}; i64
{{Cl|PRINT}} "_MK$: "; i64str
{{Cl|PRINT}} {{Text|<nowiki>"_MK$: "</nowiki>|#FFB100}}; i64str


i64 = {{Cl|_CV}}({{Cl|_INTEGER64}}, i64str)
i64 = {{Cl|_CV}}({{Cl|_INTEGER64}}, i64str)
{{Cl|PRINT}} "_CV:"; i64 '' ''
{{Cl|PRINT}} {{Text|<nowiki>"_CV:"</nowiki>|#FFB100}}; i64
{{CodeEnd}}
{{CodeEnd}}
{{OutputStart}}  
{{OutputStart}}
I64: 2305843009213693952
I64: 4099318665700534580
_MK$:
_MK$: 4i5z¢┤π8
_CV: 2305843009213693952
_CV: 4099318665700534580
{{OutputEnd}}
{{OutputEnd}}
:The _MK$ string result may not print anything to the screen, as in the example above, unless [[_CONTROLCHR]] is set to OFF.
:The _MK$ string result may not print anything to the screen, as in the example above, unless [[_CONTROLCHR]] is set to OFF.
Line 42: Line 42:


{{PageSeeAlso}}
{{PageSeeAlso}}
* [[_MK$]] {{text|(QB64 string conversion function)}}
* [[_MK$]] {{Text|(QB64 string conversion function)}}
* [[MKI$]], [[CVI]], [[INTEGER]]
* [[MKI$]], [[CVI]], [[INTEGER]]
* [[MKL$]], [[CVL]], [[LONG]]
* [[MKL$]], [[CVL]], [[LONG]]
* [[MKS$]], [[CVS]], [[SINGLE]]
* [[MKS$]], [[CVS]], [[SINGLE]]
* [[MKD$]], [[CVD]], [[DOUBLE]]
* [[MKD$]], [[CVD]], [[DOUBLE]]
* [[MKSMBF$]], [[CVSMBF]] {{text|(Microsoft Binary Format)}}
* [[MKSMBF$]], [[CVSMBF]] {{Text|(Microsoft Binary Format)}}
* [[MKDMBF$]], [[CVDMBF]] {{text|(Microsoft Binary Format)}}
* [[MKDMBF$]], [[CVDMBF]] {{Text|(Microsoft Binary Format)}}
* [[PDS (7.1) Procedures#CURRENCY|CURRENCY]]
* [[PDS(7.1) Procedures#CURRENCY|CURRENCY]]
* [[_CONTROLCHR]]
* [[_CONTROLCHR]]




{{PageNavigation}}
{{PageNavigation}}

Latest revision as of 22:14, 21 March 2023

The _CV function is used to convert _MK$, ASCII, STRING values to numerical values.


Syntax

result = _CV(numericalType, MKstringValue$)


Parameters


Description

  • The MKstringvalue$ value type must match the numerical type parameter used.
  • _MK$ string values consist of ASCII characters in the same byte length as the number value type.


Examples

Example: Using the _MK$ and _CV functions:

DIM i64 AS _INTEGER64
DIM i64str AS STRING

i64 = 4099318665700534580
i64str = _MK$(_INTEGER64, i64)

PRINT "I64:"; i64
PRINT "_MK$: "; i64str

i64 = _CV(_INTEGER64, i64str)
PRINT "_CV:"; i64
I64: 4099318665700534580 
_MK$: 4i5z¢┤π8
_CV: 4099318665700534580 
The _MK$ string result may not print anything to the screen, as in the example above, unless _CONTROLCHR is set to OFF.


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link