LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert IEEE-754 32-bit float to Hexadecimal

Solved!
Go to solution
How do I convert an IEEE-754 32-bit float data type to a hexadecimal value? Have searched the forum but the most relevant one is a convert from hex to dec. I've a device which outputs in IEEE-754 32-bit float data type. Putting an indicator will only display a value like this'UœB#Z¨'. Only by changing the properties of the indicator to display in Hex then can I view the value in Hex but I cannot do anything with the data since it is not actually in hex. Appreciate any ideas and help. Thanks!
0 Kudos
Message 1 of 14
(9,527 Views)
Use the Type Cast Function (Numeric >> Data Manipulation) to "convert" your ANSI Real number to a Floating Poit number.
Visualize the Solution

CLA

LabVIEW, LabVIEW FPGA
0 Kudos
Message 2 of 14
(9,516 Views)

Hi VADave,

 

What do I put for the 'type' input?

0 Kudos
Message 3 of 14
(9,500 Views)
Put an orange constant with single representation.
0 Kudos
Message 4 of 14
(9,483 Views)

@Ravens Fan, he wants to convert backwards. So he have to connect to the Type Input a Byte Array and not the Single Float.

Other thing is if the output shold be in the Big or Little Endian Format. If also little endian,than you have to take the Flatten To String VI.

0 Kudos
Message 5 of 14
(9,478 Views)

Eugen Graf wrote:

Ravens Fan, he wants to convert backwards. So he have to connect to the Type Input a Byte Array and not the Single Float.

Other thing is if the output shold be in the Big or Little Endian Format. If also little endian,than you have to take the Flatten To String VI.


 

You sure about that?  He doesn't exactly say where his came from.  But since he says he has goofy looking characters, that sounds like it's ASCII, thus a string indicator.  And he says he wants a number.

 

So it seems like he wants to convert a string to a number.

 

Your point about endianness is a good one to meake.

0 Kudos
Message 6 of 14
(9,474 Views)
The input is supposingly a 32-bit float and it is a string in the Labview code. I want to convert it to either a hex or dec value
0 Kudos
Message 7 of 14
(9,464 Views)

Ok, I was wrong.

 

So you have not a Float on Input, you have a binary string. You want also represent this binary string as a float. So use either the Type Cast or Unflatten From String VIs.

 

After you got a Float value from your binary string you can convert them to a number without commata and you can change the representation of this to DEC, HEX, OCT or BIN.

 

P.S. I think your problem is that you don't understand  the difference what binary and what ASCII strings mean.

Message Edited by Eugen Graf on 07-13-2009 03:25 PM
0 Kudos
Message 8 of 14
(9,460 Views)

ksin wrote:
The input is supposingly a 32-bit float and it is a string in the Labview code. I want to convert it to either a hex or dec value

 

First you need to typecast to SGL as already suggested. This will give you a numeric.

 

(Hex vs dec makes little sense. That's just a cosmetic formatting operation and does not change the underlying data. Does your SGL number contain fractional parts or are they all whole numbers?)

 

 

If you want the original 4 bytes as a hex formatted string with 8 characters (similar to what you would see when changing the original string to hex display), you would cast it to a U32 instead and format it with %08x, for example. 

0 Kudos
Message 9 of 14
(9,456 Views)

Thanks for all your suggestions. The only thing I know for sure is that the device's (a temperature controller) output is an IEEE 754 32-bit float data type as mentioned in it's spec. The VI that I'm using was provided by the company but they do not provide support for the code. So I'm actually left guessing what the data format is coming out of the VISA read module. After a whole day and you guys' help, it's probably a binary string. String I know for sure cus it's pink!

 

Just in case you're wondering, I do not have much experience dealing with data manupilation and Labview itself. Thanks for your paitence.

0 Kudos
Message 10 of 14
(9,429 Views)