Hey Sheldon

With NumPy you can use dtype's newbyteorder method to convert any dtype's
byte order to an order you specify:

In [1]: import numpy as N
In [2]: x = N.array([1],dtype='<i4')
In [3]: y = N.array([1],dtype='>i4')
In [4]: xle = N.asarray(x, dtype=x.dtype.newbyteorder('<'))
In [5]: yle = N.asarray(y, dtype=y.dtype.newbyteorder('<'))

In [6]: x.dtype
Out[6]: dtype('<i4')

In [7]: y.dtype
Out[7]: dtype('>i4')

In [8]: xle.dtype
Out[8]: dtype('<i4')

In [9]: yle.dtype
Out[9]: dtype('<i4')

Regards,

Albert

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:numpy-
> [EMAIL PROTECTED] On Behalf Of Johnston Sheldon
> Sent: 21 June 2006 15:31
> To: Numpy-discussion@lists.sourceforge.net
> Subject: [Numpy-discussion] LittleEndian
> 
> Hi,
> 
> Can someone give a brief example of the Numeric function LittleEndian?
> 
> I have written two separate functions to read binary data that can be
> either LittleEndian or BigEndian (using byteswapped() ) but it would be
> great with just one function.



_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to