Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Data Manipulation > Binary Data > ByteOrdering >

ByteOrdering

ByteOrdering
is an option for BinaryRead, BinaryWrite, and related functions that specifies what ordering of bytes should be assumed for your computer system.
  • corresponds to big endian (appropriate for PowerPC and many other processors); corresponds to little endian (appropriate for x86 processors).
  • corresponds to having the most-significant byte first; to having the least-significant byte first.
$ByteOrdering gives the byte ordering on this machine:
Create a file with a 32-bit integer:
Read the data from the file:
Read the data with reverse byte ordering:
Recreate the correct interpretation using Mathematica functions:
$ByteOrdering gives the byte ordering on this machine:
In[1]:=
Click for copyable input
Out[1]=
 
Create a file with a 32-bit integer:
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Read the data from the file:
In[4]:=
Click for copyable input
Out[4]=
In[5]:=
Click for copyable input
Read the data with reverse byte ordering:
In[6]:=
Click for copyable input
Out[6]=
Recreate the correct interpretation using Mathematica functions:
In[7]:=
Click for copyable input
Out[7]=
In[8]:=
Click for copyable input
Out[8]=
In[9]:=
Click for copyable input
New in 5.2
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF