Skip to content

CVS


Converts a 32-bit integer or 4-byte string to a single-precision variable

Syntax

vb
declare function Cvs ( byval i as integer ) as single
declare function Cvs ( byref str as const string ) as single

Usage

result = Cvs( i )
result = Cvs( str )

Parameters

i

A 32-bit Integer with a binary copy of a single-precision variable stored in it.

str

A String at least 4 bytes in length with a binary copy of a single-precision variable stored in it.

Return Value

Returns a Single value holding a binary copy of the input value.

Description

Does a binary copy from a 32-bit Integer or 4-byte String to a Single variable. A value of zero (0.0) is returned if the string is less than 4 bytes in length. The result will make sense only if the parameter contained a IEEE-754 formatted single-precision value, such as one generated by Cvi or Mks.

This function is useful to read numeric values from buffers without using a Type definition.

Examples

start GeSHi

vb
Dim f As Single, i As Integer
f = 1.125
i = CVI(f)

Print Using "i = _&H&"; Hex(i)
Print Using "cvs(i) = &"; CVS(i)

end GeSHi

Differences from QB

  • QB did not support integer arguments.

See also

  • Mks
  • Cvd
  • Cvi

Back to DocToc

Translated from FreeBASIC official docs. Contact us for removal if infringed.
FreeBASIC is an open-source project, not affiliated with Microsoft