BitConverter.ToSingle returns a single-precision float number converted from four bytes
Imports System
Imports Microsoft.VisualBasic
Module BytesToSingleDemo
Sub BAToSingle( bytes( ) As Byte, index As Integer )
Dim value As Single = BitConverter.ToSingle( bytes, index )
Console.WriteLine( value )
End Sub
Sub WriteMultiLineByteArray( bytes( ) As Byte )
Const rowSize As Integer = 20
Dim iter As Integer
For iter = 0 To bytes.Length - rowSize - 1 Step rowSize
Console.Write(BitConverter.ToString( bytes, iter, rowSize ) )
Next iter
Console.WriteLine( BitConverter.ToString( bytes, iter ) )
End Sub
Sub Main( )
Dim byteArray as Byte( ) = { _
190, 121, 255, 255, 127, 255, 255, 127, 127, 1, _
0, 0, 0, 192, 255, 0, 0, 128, 255, 0, _
0, 128, 127 }
BAToSingle( byteArray, 0 )
End Sub
End Module
Related examples in the same category