08-16-2016 03:59 AM
Hi Richard,
drawbacks: it's the solution requiring the most computational power.
But then any modern computer is able to calc this FOR loop with 4 iterations within nanoseconds…
Why don't you use solution 4 ("I32_4")? It basically does the same with less (polymorph) operations…
08-16-2016 05:28 AM
@lvrichard wrote:Ive noticed i'm not getting consistent results from the type cast function, which is annoying!!.
That makes me think there is something wrong with your original data array. Maybe you are getting too many or not enough bytes sometimes. Why is the data coming from?
08-23-2016 01:53 PM
@lvrichard wrote:
Ive noticed i'm not getting consistent results from the type cast function, which is annoying!!
Please define the word "inconsistent". Is it sometimes wrong, almost right, or always wrong? My best guess is that your input data array is not U8, but some other integer type. It could also be a byte order thing as Ben already mentioned.
Can you attach a simple VI containing your data that generates incrrect result as a diagram constant?
10-19-2018 06:08 AM
Hi
Thanks for posting the solution to this query. However, I just wanted to know how to convert a byte array, having more than 4 bytes into integer. This solution works only for 4-byte array.
Shall be highly grateful for your response. Thanks
10-19-2018 06:21 AM - edited 10-19-2018 06:22 AM
10-19-2018 07:16 AM
@sakshirawal wrote:
Hi
Thanks for posting the solution to this query. However, I just wanted to know how to convert a byte array, having more than 4 bytes into integer. This solution works only for 4-byte array.
Shall be highly grateful for your response. Thanks
What do the other bytes in the array besides the four represent? You can just discard them and only use the 4 you using either Array Subset or Delete from Array.
10-19-2018 10:54 AM
@sakshirawal wrote:Thanks for posting the solution to this query. However, I just wanted to know how to convert a byte array, having more than 4 bytes into integer. This solution works only for 4-byte array.
You added to an old thread with a very vague question that cannot be given a very specific answer.
In general, the provided solution works for anything where the input and output have matching amounts of bytes overall. You might also need to worry about byte order.
Easiest would be if you attach a simplified version of your code showing us what you have and what you want to get out of it.
10-20-2018 12:55 AM
@crossrulz wrote:
Just something to keep in mind: Endianess has often bitten me in the butt. LabVIEW currently uses Big Endian for all of its data storage, so the Type Cast will work. But I prefer to use the Unflatten From String approach just in case I find that the data string I am recieving is actually Little Endian (there is an input for the Unflatten From String for Endianess).
I've actually had it where the incoming data had a different endianness depending on the source. Same data format, different endianness. Thank you, Unflatten from String, for allowing me to choose the endianness based on the source!
10-20-2018 12:57 AM
@lvrichard wrote:
Hi Crossrulz,
Ive noticed i'm not getting consistent results from the type cast function, which is annoying!! However, the self indexing for loop Gerd posted seems to be the most reliable method. Is there any drawbacks to using the method? Is it more intensive etc??
Thanks,
Richard.
If you can't fill up the data type with data, you're going to get weird results, because the missing byte(s) will shift the data one way or the other.