05-15-2012 02:32 PM - edited 05-15-2012 02:33 PM
I'm done a lot of tinkering and searching, but despite all the very similar examples I've found, I feel I'm limited by my lack of programming knowledge. I am given values like 0000c641 which I have to convert to 41C60000
which should convert to 24.75 as an IEEE754 standard 32-bit single precision float. I've seen very similar examples with boxing and unboxing, but I simply can't figure it out. Thanks.
Solved! Go to Solution.
05-15-2012 03:10 PM
Boxing and unboxing? Not sure what you're referring to there. We need to be perfectly clear on what the input is. You said it's a "hex string". Well, that's a little vague. Is it a string control/constant that's set to "normal display mode", and you have the character sequence of 0000c641. Note that I am explicitly saying characters there. This is different than having the string set to "hex display mode" and seeing the value 0000c641. Note again that I'm being explicit there. Two VERY different things, requiring two VERY different solutions.
05-15-2012 03:16 PM
I'm pulling these from VISA reads from my instrument, but as it stands now, I have the hex strings are string controls in NORMAL MODE. So calling them character sequences as opposed to hex strings would be more accurate I suppose.
05-15-2012 03:28 PM
Endianness usually refers to word (int) order, whereas in you example the byte order must be inverterd accross the whole 4 bytes....
I think this is what you want - albeit brute force....
05-15-2012 03:41 PM - edited 05-15-2012 03:42 PM
OK, then if you have actual letters coming in, there's a couple of ways you can do this. You can basically rearrange the string to get it in the order that LabVIEW expects. Or, you can do the same thing by using the data manipulation functions:
05-15-2012 03:44 PM - edited 05-15-2012 03:45 PM
@S1ack wrote:
Endianness usually refers to word (int) order, whereas in you example the byte order must be inverterd accross the whole 4 bytes....
I think this is what you want - albeit brute force....
That method won't work, since the user indicated they have a string coming in, not a number.
Besides, there's a far simpler way. See method 2 from my response. Just connect the numeric control directly to the Flatten to String function.
05-15-2012 03:50 PM
smercurio_fc wrote:Besides, there's a far simpler way. See method 2 from my response. Just connect the numeric control directly to the Flatten to String function.
Unflatten from String looks like the way to go here, but just wanted to throw in one more option. It's a lot easier to reverse the bytes after converting to a number, rather than rearranging the letters in the string:
05-15-2012 03:54 PM - edited 05-15-2012 03:56 PM
With hex characters in a string in normal mode.
05-15-2012 03:56 PM
@smercurio_fc wrote:
That method won't work, since the user indicated they have a string coming in, not a number.
Indeed, that information appeared whilst composing the reply.
05-15-2012 04:00 PM
Ah, so many options, so few cats in this world to skin...