MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

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


  • Prev by Date: Displaying results in a column
  • Next by Date: a[n],b[n]
  • Previous by thread: Re: Re: Re: Displaying results in a column
  • Next by thread: a[n],b[n]