Greg,
Is there any particular reason why there is no LabVIEW byteswap
command which functions on a double?
Or a float for that matter?
The only ones provided byteswap 16 bit or 32 bit integers.
-- Harold
In article <3E1A32A0.9080507@austin.rr.com>,
Greg McKaskle wrote:
> > I am nonetheless still confused... When I typecast a double into a
> > structure who's first element is a 32 bit integer and second element
> > is a 32 bit unsigned integer, I found the signed integer contained the
> > most significant bits of the double and the unsigned integer contained
> > the least significant bits, which is of course what I wanted. But
> > that's confusing because it is what I would expect on a big endian
> > machine, i.e., the most significant bits first...
> >
> > One conclusion I might draw is that the typecast function makes things
> > consistent from platform to platform, i.e., makes it appear as though
> > I'm working in a big endian, and that it is utterly different from a C
> > union. I don't know if that is correct, but I can test it.
>
>
> Ah. I should have mentioned that typecast is equivalent to casting from
> the original type to string and then casting from the string to the
> other type. As you supposed, this is to make the diagram run the same
> on all sorts of platforms. This means that when going from an array of
> int32s to an array of int16s, the int16s will always be in the same order.
>
> > But what I
> > found was that in order to interpret the data correctly, I had to swap
> > the bytes of the embedded unicode strings, and swap the bytes and
> > words of the 32 bit string lengths and structure offsets. Based on
> > what you've said, the API call might be returning data in big endian.
> > There is an endianess boolean parameter to the structure which I
> > ignored since I assumed I was going to have to sort it out anyway. If
> > in big endian, perhaps I can use the unflatten node rather than doing
> > it by hand.
> >
>
> If you use typecast, you will need to swap things. If you have a
> pointer being returned, then you usually arrange for the type to be a LV
> type that is accurate rather than a generic pointer than needs to be
> cast. If you can descibe the output types in the DLL dialog accurately,
> then no swapping is needed.
>
> I hope this helps to sort things out, but if not, provide more details
> and ask again.
>
> Greg McKaskle
>