LabVIEWForum.de
hex to 32bit float - Druckversion

+- LabVIEWForum.de (https://www.labviewforum.de)
+-- Forum: LabVIEW (/Forum-LabVIEW)
+--- Forum: LabVIEW Allgemein (/Forum-LabVIEW-Allgemein)
+---- Forum: Instrument IO & VISA (/Forum-Instrument-IO-VISA)
+---- Thema: hex to 32bit float (/Thread-hex-to-32bit-float)



hex to 32bit float - atbab3 - 16.10.2012 14:20

Hey there,

i communicate with a device by sending and receiving hexadecimal strings.

for example: by sending the command 01 04 00 00 00 02 71 CB I receive 01 04 04 3E A8 53 96 CB 12

Now I need to translate that into a number. In this case it should be 0,3287627

I have a demoprogramm which is working, but I can't comprehend how.

So my problem is to translate that hex number into 32bit float

[attachment=41875] --> demoprogramm

[attachment=41876] --> my version


RE: hex to 32bit float - GerdW - 16.10.2012 14:26

Hi atbab3,

it works like this:
[attachment=41878]
(String constant in hex display mode!)


RE: hex to 32bit float - atbab3 - 17.10.2012 08:25

Thanks a lot!!


RE: hex to 32bit float - Lucki - 18.10.2012 07:42

@Gerd
Um das hier herauszufinden, sollte man eigentlich Kryptologie studiert haben. Aber Du bist wahrscheinlich ein Naturtalent, alle Achtung..


RE: hex to 32bit float - GerdW - 18.10.2012 07:46

Hallo Lucki,

so schwer war das doch gar nicht, wenn man den Screenshot des "Demoprogramms" zu Hilfe nimmt.
Dort steht schon, dass es sich um 32bit floats handelt, es werden die benötigten Bytes angezeigt und das Ergebnis der Konvertierung. Am "3E" als erstem Byte (in Zusammenhang mit dem gewünschten Ergebnis) erkennt man, dass es sich (mit 95% Wahrscheinlichkeit) um IEEE-Standard-SGLs handelt. Dann nur noch TypeCast und fertig...