Skip to content
Paul Squires edited this page Oct 19, 2026 · 2 revisions

Home › String Functions › CVS

CVS

Reads a Single back from a 4-byte string.

Syntax

Declare Function CVS ( ByVal i As Integer ) As Single
Declare Function CVS ( ByRef str As Const String ) As Single

Parameters

  • i
  • str

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.

Return Value

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

Remarks

Usage

result = CVS( i )

result = CVS( str )

Differences from QB

  • QB did not support integer arguments.

See also

Examples

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)

Category: String Functions
Kind: function


Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.

Clone this wiki locally