LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Who know how to convert float number to hexadecimal string ?

Hi Mike,
 
How to use a Flatten to String to convert Sgl to Hex ?
 
Can you pl show it ?
- Partha ( CLD until Oct 2027 🙂 )
Message 11 of 23
(3,315 Views)
Hi parthabe,

have you tried this:

(It doesn't give a string of hex formatted numbers, it gives you a string containing the byte values.)

Message Edited by GerdW on 05-09-2007 10:07 AM

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 12 of 23
(3,313 Views)

Hi GerdW,

I tried this & understood what is happening, thats why my question...

From a beginner's point of view, this will be a bit confusing, that is what I meant indirectly. Smiley Wink

- Partha ( CLD until Oct 2027 🙂 )
Message 13 of 23
(3,308 Views)
Perhaps the name of the function might at first seem counter-intuitive, but if you think about it and read the description of what flatten to string does, it becomes obvious that this is exactly what this function is for. In addition, it demonstrates that the only difference between a string and an array of U8s is how it is interpretted for display. In fact the reprepresentation of both in memory is identical.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 14 of 23
(3,296 Views)

Will the method of TypeCast still true for 64 bit floating point number?

I used C++ and the result I have is

1 = 3F800000 (32bits)

   = 3FF0000000000000 (64bits)

 

I got the similar value with 32bits in LabView but different value for 64bits: 3F80000000000000 (64bits).

 

0 Kudos
Message 15 of 23
(2,787 Views)

Oh, I sorry, I got answer myself:

32bits Single Precision

64bits Double Precision

0 Kudos
Message 16 of 23
(2,788 Views)

I've got a similar problem in that my data (32-bit and 64-bit) are arriving as blocks of 4 or 8 bytes of strings.

 

I cast to 32 (or 64) float, then use the join numbers function to get the bits held as single 32 or 64 number format, but I now need to rotate through to identify the sign, exponent and fraction. But I've just discovered the rotate function drops the bits I want, so I'll have to chop about with very messy code. Is there an easier way?!

0 Kudos
Message 17 of 23
(2,735 Views)

Your question is not completely clear. Can you provide more details on precisely what you're doing?

 

You may wish to start a new post on this so it gets more visibility. If you do, please make a note in this thread to indicate the discussion has moved.

0 Kudos
Message 18 of 23
(2,726 Views)

grahamwebb wrote:

I've got a similar problem in that my data (32-bit and 64-bit) are arriving as blocks of 4 or 8 bytes of strings.

 

I cast to 32 (or 64) float, then use the join numbers function to get the bits held as single 32 or 64 number format, but I now need to rotate through to identify the sign, exponent and fraction. But I've just discovered the rotate function drops the bits I want, so I'll have to chop about with very messy code. Is there an easier way?!


None of this makes sense! Join numbers is for intergers (blue), not floats (orange), so it seems you are actually casting to integers. If you would cast to floats, the number will be correct, no need to dig bitwise into sign, exponent, or mantissa, everything will automatically fall into place.

 

(The only problem you might encounter, is byte order. If you string is little endian, you need to reverse the string first.)

Message Edited by altenbach on 06-12-2009 09:00 AM
0 Kudos
Message 19 of 23
(2,716 Views)

It's been a long day!

 

Yes I cast to 8-bit ints, joined them and planned to rotate through to get signs, exp. etc. But as you say I have overlooked the bleedin' obvious - cast to 32 or 64 bit floats in the first place! .. which I have done in another part of the program!! arghh! where's my well-written documentation?

0 Kudos
Message 20 of 23
(2,704 Views)