Mathematica > 数据处理 > 导入和导出 > Binary >

Binary

Sequence of binary data objects.
Binary format.
Stores a uniform sequence of simple or compound data types.
  • Import reads raw binary data as a sequence of elementary or compound data types.
  • Export generates binary files from uniform lists of elementary or compound data types.
  • Import imports any binary file as a list of bytes.
  • Export exports a list of byte-size integers to a binary file.
  • The format must be specified when importing or exporting raw binary files.
  • Import or Import imports the specified element from a binary file.
  • Import imports multiple elements.
  • Export creates a binary file by treating expr as specifying element elem.
  • See the reference pages for full general information on Import and Export.
"Elements" elements and options available in this file
"Rules"full rules for each element and option
"Options"rules for options, properties, and settings
  • Data representation elements:
"Bit"zeros and ones
"Byte"integers in the range 0 to 255
"Character8"8-bit characters
"Character16"16-bit characters
"Integer8"8-bit signed integers
"Integer16"16-bit signed integers
"Integer24"24-bit signed integers
"Integer32"32-bit signed integers
"Integer64"64-bit signed integers
"Integer128"128-bit signed integers
"UnsignedInteger8"8-bit unsigned integers
"UnsignedInteger16"16-bit unsigned integers
"UnsignedInteger24"24-bit unsigned integers
"UnsignedInteger32"32-bit unsigned integers
"UnsignedInteger64"64-bit unsigned integers
"UnsignedInteger128"128-bit unsigned integers
"Real32"IEEE single-precision numbers
"Real64"IEEE double-precision numbers
"Real128"IEEE quad-precision numbers
"Complex64"IEEE single-precision complex numbers
"Complex128"IEEE double-precision complex numbers
"Complex256"IEEE quad-precision complex numbers
  • For any data representation element type, Import can be used as a shorthand for Import.
  • Trailing bytes are ignored if the size of the imported file is not a multiple of the data size.
  • General option:
ByteOrdering-1what byte ordering to use
"HeaderBytes"0how many bytes to skip at the beginning of the file
  • Data representation option:
"DataFormat"Automaticspecifies a compound object as a list of basic data types
  • With a setting , Import and Export interpret a raw binary file as a sequence of objects of the form .
  • Import reads file as an alternating sequence of 8-bit characters and 32-bit integers.
Convert a string of characters to a list of byte-valued integers:
The format specification can be omitted when importing elementary data types:
Export pairs of integers and reals to a binary sequence of 8-bit integers and double-precision reals:
Convert the previous output back to an array of numbers:
Verify that each number pair was converted to 1+8 bytes:
Convert a string of characters to a list of byte-valued integers:
In[1]:=
Click for copyable input
Out[1]=
The format specification can be omitted when importing elementary data types:
In[2]:=
Click for copyable input
Out[2]=
 
Export pairs of integers and reals to a binary sequence of 8-bit integers and double-precision reals:
In[1]:=
Click for copyable input
Out[1]=
Convert the previous output back to an array of numbers:
In[2]:=
Click for copyable input
Out[2]=
Verify that each number pair was converted to 1+8 bytes:
In[3]:=
Click for copyable input
Out[3]=
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
格式:   HTML  |  CDF