From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Conversion to float

Solved!
Go to solution
How to convert U32 array to IEEE-754 32 bit single precision floating point in LabVIEW ? SGL doesn't seem to work.
0 Kudos
Message 1 of 7
(6,484 Views)

SGL is correct. However you need to remember that LabVIEW is big endian, so you might need to convert from/to little endian when communicating with external programs or writing to binary files, etc.. What are you planning to do with it?

 

Please give an example of what you are trying to convert, what you expect to get, and what you are getting instead.

0 Kudos
Message 2 of 7
(6,482 Views)
I'm trying to convert U32 number to float....
For example I need to convert 1903 to float...I expect to get it as 2.66667098e-042
But I'm getting the same value 1903 using SGL
0 Kudos
Message 3 of 7
(6,463 Views)
Solution
Accepted by topic author RaoSudeshna

Hi Rao,

 

a perfect moment to tell strongly advice you to attach VIs or snippets when you have problems with your LabVIEW VIs!

 

From your writing I guess you use the function "To SGL", which will convert the value from U32 datatype to SGL datatype.

You need to use Typecast to reinterprete the memory content of the U32 as SGL…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 7
(6,449 Views)

@RaoSudeshna wrote:
I'm trying to convert U32 number to float....
For example I need to convert 1903 to float...I expect to get it as 2.66667098e-042
But I'm getting the same value 1903 using SGL

I beleive there is a confusion here. The OP mixes the number format with data type. The data type is one thing, the format is another. To change the number format of a numeric indicator, right click on it, go to "Display format", and chose "Scientific":

 

Untitled.png

0 Kudos
Message 5 of 7
(6,441 Views)

The main problem was that you used the term "conversion", which is typically not used for type casting operations.

 

Apparently, your problem is solved, bu here's an old summary on the differences between conversion and casting (and flattening/unflattening).

 

 

 

Message 6 of 7
(6,407 Views)

Ok, so not the OP but me who was confused 🙂

 

0 Kudos
Message 7 of 7
(6,398 Views)