{{fbdoc item="title" value="CVI"}}----
Converts a single-precision floating-point number or string to an integer variable using a binary copy

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Cvi** ( [[KeyPgByval byval]] //sng// [[KeyPgAs as]] [[KeyPgSingle single]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]
	[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Cvi** ( [[KeyPgByref byref]] //str// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]
	[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Cvi**<//bits>// ( //expr// [[KeyPgAs as]] [[DataType]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]<//bits//>
##
{{fbdoc item="usage"}}##
	//result// = **Cvi**( //sng// )
	//result// = **Cvi**( //str// )
	//result// = **Cvi**<//bits//>( //expr// )
##
{{fbdoc item="param"}}
	##//sng//##
		A ##[[KeyPgSingle Single]]## floating-point number with a binary copy of an integer variable stored in it.
	##//str//##
		A ##[[KeyPgString String]]## with a binary copy of an integer variable stored in it.
	##//bits//##
		Specifies a size of integer type to return.  The types and sizes of ##//expr//## accepted will depend on the corresponding function called.
	##//expr//##
		An expression that will be copied into an ##[[KeyPgInteger Integer]]<//bits//>##.

{{fbdoc item="ret"}}
	An ##[[KeyPgInteger Integer]]## or ##[[KeyPgInteger Integer]]<//bits//>## variable containing a binary copy of the input expression.

{{fbdoc item="desc"}}
	Returns an integer value using the binary data contained in a ##[[KeyPgSingle Single]]##, or a ##[[KeyPgString String]]##.  A value of zero (##0##) is returned if the string contains fewer characters than the size of the return type.

	##**Cvi**## is used to convert strings created with ##[[KeyPgMki Mki]]##.

	This function can also be used to convert 32-bit integer values from a memory or file buffer without the need for a ##[[KeyPgType Type]]## structure.  However, just as with the type structure, special care should be taken when using ##**Cvi**## to convert strings that have been read from a buffer.

	##**Cvi**## supports an optional ##<//bits//>## parameter before the argument.  If ##//bits//## is ##16##, ##[[KeyPgCvshort Cvshort]]## will be called instead; if ##//bits//## is ##32##, ##[[KeyPgCvl Cvl]]## will be called; if ##//bits//## is ##64##, ##[[KeyPgCvlongint Cvlongint]]## will be called.  The return type and accepted argument types will depend on which function is called.  See each function's page for more information.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/strings/cvi.bas"}}%%(freebasic)
dim i as integer, s as string
s = "ABCD"
i = cvi(s)
print using "s = ""&"""; s
print using "i = _&H&"; hex(i)
%%

{{fbdoc item="lang"}}
	- In the //[[CompilerOptlang -lang qb]]// dialect, ##**Cvi**## expects a 2-byte string, since a QB integer is only 16 bits.  Only the first two bytes of the string are used, even if the string happens to be longer than two bytes.
	- In the //[[CompilerOptlang -lang qb]]// dialect, ##**Cvi**## will not take a floating-point argument, since a QB integer is only 16 bits and there is no 16-bit floating-point data type.  Instead, ##**Cvi**<32>##/##**Cvi**<64>## or ##[[KeyPgCvl Cvl]]##/##[[KeyPgCvlongint Cvlongint]]## may be used.

{{fbdoc item="diff"}}
	- In QB an error occurs if the string passed is fewer than two bytes in length.
	- QB did not support floating-point arguments.
	- QB did not support a ##<//bits//>## parameter.

{{fbdoc item="see"}}
	- ##[[KeyPgMki Mki]]##
	- ##[[KeyPgCvshort Cvshort]]##
	- ##[[KeyPgCvl Cvl]]##
	- ##[[KeyPgCvlongint Cvlongint]]##
	- ##[[KeyPgInteger Integer]]##

{{fbdoc item="back" value="CatPgString|String Functions"}}