I want to read 4 byte with IEEE floating point format and convert to decimal number in vb.net, and need to function for shift bits to left in vb .net.

32 bit IEEE floating point has this format:

S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF

0 1 8 9 31

V=(-1)**S * 2 ** (E-127) * (1.F) where "1.F" is intended to represent the binary number created by prefixing F with an implicit leading 1 and a binary point.

can some one help me?

thanks.

I wrote this in VB6, hope it helps

Function Bin2Float(stringdata As String) As Double

Dim i As Integer

Dim signed_part As String

Dim exponent_part As String

Dim floating_part As String

Dim signed As Integer

Dim exponent As Integer

Dim float_digit As Integer

Dim floating As Double

Dim float_number As Double

Dim float_factor As Double

signed_part = Left$(stringdata, 1)

exponent_part = Mid$(stringdata, 2, 8)

floating_part = Right$(stringdata, 23)

signed = Bin2Dec(signed_part)

exponent = Bin2Dec(exponent_part)

For i = 1 To 23

float_digit = Bin2Dec(Mid$(floating_part, i, 1))

If float_digit = 1 Then

floating = float_digit / (2 ^ i)

float_number = float_number + floating

End If

Next

If exponent > 0 Then

float_factor = 1 + float_number

ElseIf exponent = 0 Then

float_factor = float_number

End If

'

' Debug.Print signed

' Debug.Print exponent

' Debug.Print float_factor

If exponent > 0 And exponent < 255 Then

Bin2Float = ((-1) ^ signed) * (2 ^ (exponent - 127)) * float_factor

ElseIf exponent = 0 Then

Bin2Float = ((-1) ^ signed) * (2 ^ -126) * float_factor

ElseIf exponent = 255 Then

Bin2Float = 0

End If

End Function

And this is Bin2Dec

Function Bin2Dec(stringdata As String) As Long

Dim n As Integer

Dim a As Integer

Dim x As String

n = Len(stringdata) - 1

a = n

Do While n > -1

x = Mid$(stringdata, ((a + 1) - n), 1)

Bin2Dec = IIf((x = "1"), Bin2Dec + (2 ^ (n)), Bin2Dec)

n = n - 1

Loop

End Function