02-03-2016 02:32 PM - edited 02-03-2016 02:32 PM
No! The array is an Array of Bytes -- there's nothing to "Byte-Swap". You aren't reversing bits, you are reversing entire bytes. So if you have a Dbl, which takes 8 Bytes, and you create an Array of Bytes (let's number them 1, 2, 3, 4, 5, 6, 7, 8), reverse this array (8, 7, 6, 5, 4, 3, 2, 1), and then put this back together as though it were a Dbl, you would have ..."reversed the order of the Bytes representing the Double", exactly the difference between Big Endian and Little Endian, namely the order of the bytes is reversed.
Bob (it's really very simple, as am I) Schor
P.S. -- regarding your signature, that is the Question, is it not?
02-03-2016 02:38 PM
@DailyDose wrote:
@nathand wrote:What you really want to do is flatten to a string, then unflatten to a 64-bit scalar with the endianness set, then typecast that to an array of U16 or whatever. At that point a typecast to a U8, followed by a reverse array, then typecast back to U16 might be just as easy.
This seems like a bit much. Sounds like the Reverse 1D Array and byte swap will suffice for a U16. But what about in the case of a 32 bit? Both of the two examples I originally posted sound like they will not work.
A typecast to U8 followed by Reverse 1D Array will swap endianness for any single value; then you can typecast the reversed 1D array of U8 to whatever you want and the byte order won't change, you'll just be combining bytes. Does that help? If not, I'm not sure what you're asking.
02-03-2016 03:10 PM
@nathand wrote:
@DailyDose wrote:
@nathand wrote:What you really want to do is flatten to a string, then unflatten to a 64-bit scalar with the endianness set, then typecast that to an array of U16 or whatever. At that point a typecast to a U8, followed by a reverse array, then typecast back to U16 might be just as easy.
This seems like a bit much. Sounds like the Reverse 1D Array and byte swap will suffice for a U16. But what about in the case of a 32 bit? Both of the two examples I originally posted sound like they will not work.
A typecast to U8 followed by Reverse 1D Array will swap endianness for any single value; then you can typecast the reversed 1D array of U8 to whatever you want and the byte order won't change, you'll just be combining bytes. Does that help? If not, I'm not sure what you're asking.
I've been thinking this in terms of Most Significant Bit -> Least Significant Bit then changed to Least Significant Bit -> Most Significant Bit. But now I see that's incorrect. It's Byte... not Bit? Change the Bytes around, but don't change the bits, correct?
02-03-2016 03:15 PM
@DailyDose wrote:I've been thinking this in terms of Most Significant Bit -> Least Significant Bit then changed to Least Significant Bit -> Most Significant Bit. But now I see that's incorrect. It's Byte... not Bit? Change the Bytes around, but don't change the bits, correct?
Correct. Endianness is about bytes. A byte is an atomic unit, you never need to worry about bit order within a byte.
02-03-2016 03:17 PM
Ok, thank you. I'm sorry. You guys probably said that multiple times and I just straight up missed it. Thank you!
02-03-2016 03:45 PM
@Bob_Schor wrote:
P.S. -- regarding your signature, that is the Question, is it not?
I believe it is? Which I guess.... True is the meaning of life? Ha
Also, I noticed you basically answered my question and I had tunnel vision or something. My bad.