LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert float string to 32-bit Hex

Solved!
Go to solution

Hi: - I’m hoping someone can help.

 

I have a string containing a float number “3.5266287875071523e-38”

 

I need to convert this to a 32 bit HEX string.  From http://babbage.cs.qc.edu/IEEE-754/ I know the correct answer is 0x”01400208”. 

 

I can easily get the 64-bit answer (3828 0041 0000 0000)

 

I’ve searched and searched the web - I tried many different approaches – all without success.  The closest I've been able to get is the attached VI.  I think I’m missing a nugget of knowledge. 

 

Thanx to whomever can take some time and get me un-stuck

0 Kudos
Message 1 of 4
(3,830 Views)
Solution
Accepted by topic author Mr_Monday

Hi Monday,

 

try this one:

check.png

Remember: SGL datatype uses 32 bits...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 4
(3,823 Views)

Just wire a SGL constant to the Default input of Fract/exp String to number.

 

(that will give you a 32 bit IEEE-754 represttation- and then when the SGL is flattened you get

Untitled.png


"Should be" isn't "Is" -Jay
Message 3 of 4
(3,821 Views)

Thanx guys - both of you:  BOTH solutions are good - either let the stringToNumber conversion create the single or convert it after the fact.  As GerdW points out, the nugget I was missing was that SGL are 32 bit.  I appreciate your time

 

I won't admit to how long I tried to solve this and embarrased to find that the answer is so straightforward <blush>

0 Kudos
Message 4 of 4
(3,811 Views)