Home > Net >  The small white ask bosses hexadecimal string in VB.NET and transform of type double
The small white ask bosses hexadecimal string in VB.NET and transform of type double

Time:09-27

As title, I'll be back next bit machine communication data is hexadecimal string, want to transform it into a floating point number, find a number of ways are not achieve them, to the BBS for help
For example,
16 # 3 f800000=1.0
16 # 3 fc2f1a9=1.53

CodePudding user response:

Before 3 f800000 plus' & amp; H 'equals & amp; H3F80

NumHex="& amp; H "& amp; strHex

CodePudding user response:

reference 1st floor eaqpi response:
before 3 f800000 plus' & amp; H 'equals & amp; H3F80

NumHex="& amp; H "& amp; StrHex


Bosses, can again a bit more points

CodePudding user response:

 
Dim STR As String="3 f800000"
Dim I As Integer=CInt (Val (" & amp; H "& amp; STR))

CodePudding user response:

The
reference 3 floor eaqpi response:
 
Dim STR As String="3 f800000"
Dim I As Integer=CInt (Val (" & amp; H "& amp; STR))


The results of this as if it is plastic...
What I want is the result of the double data

CodePudding user response:

Will not be an integer into a double, will CDBL cint?

CodePudding user response:

The
reference 3 floor eaqpi response:
 
Dim STR As String="3 f800000"
Dim I As Integer=CInt (Val (" & amp; H "& amp; STR))


Bosses how are you, just take your code knocked down, found that display data is plastic
According to your way, I added a line of code, the display should be double, but I don't need to display or plastic, the 1.0 data

 Dim STR As String="3 f800000" 
Dim I As Integer=CInt (Val (" & amp; H "& amp; STR))
Dim j As Double=CDbl (Val (" & amp; H "& amp; STR))


Label1. Text=I
Label2. Text=j


CodePudding user response:

reference 5 floor eaqpi reply:
will not change the integer to double, to CDBL cint?


Has changed, and add the fomart, feel or you don't like change

 Dim STR As String="3 f800000" 
Dim I As Integer=CInt (Val (" & amp; H "& amp; STR))
Dim j As Double=CDbl (Val (" & amp; H "& amp; STR))
Dim As Double=k Format (I, "0.0")
Label1. Text=k
Label2. Text=k


CodePudding user response:

The search on the net have a decimal to hexadecimal conversion function, and they were afraid I use one, don't have my computer now, look for yourself

CodePudding user response:

 Dim I=& amp; H3F800000 
Dim j=& amp; H3FC2F1A9
Dim fi=BitConverter. ToSingle (BitConverter GetBytes (I), 0)
Dim fj=BitConverter. ToSingle (BitConverter GetBytes (j), 0)

CodePudding user response:

If the input string,

 Private Sub SurroundingSub () 
Dim si="3 f800000"
Dim sj="3 fc2f1a9"
Dim I=Integer. The Parse (si, System. Globalization. NumberStyles. HexNumber)
Dim j=Integer Parse (sj, System. Globalization. NumberStyles. HexNumber)
Dim fi As Single=BitConverter. ToSingle (BitConverter. GetBytes (I), 0)
Dim fj As Single=BitConverter. ToSingle (BitConverter. GetBytes (j), 0)
End Sub

CodePudding user response:

references 9 f github_36000833 response:
 Dim I=& amp; H3F800000 
Dim j=& amp; H3FC2F1A9
Dim fi=BitConverter. ToSingle (BitConverter GetBytes (I), 0)
Dim fj=BitConverter. ToSingle (BitConverter GetBytes (j), 0)



I the afternoon that day is also touch the instruction, to now, thank you requested

CodePudding user response:

 
Dim x As Integer=& amp; H3F80
Dim As Double=y Convert. ToDouble (x)
  • Related