mixed ByteOrdering
- To: mathgroup at smc.vnet.net
- Subject: [mg104882] mixed ByteOrdering
- From: sibir <martin.rommel at gmail.com>
- Date: Thu, 12 Nov 2009 06:06:11 -0500 (EST)
I have some binary files with mixed ByteOrdering. The actual data is little endian but the metadata in the header is big endian. Is there a clever way to swap the bytes in a short integer? My first shot looks rather ugly: swapBytes[b_] := BitOr[BitShiftLeft[BitAnd[255, b] 1, 8], BitShiftRight[b, 8]] Cheers