关于二进制文件储存格式

来源:互联网 发布:阿里布达年代祭百度云 编辑:程序博客网 时间:2024/05/19 18:17

matlab中给出以下几种类型,供参考:

machinefmt — Order for reading bytes'n' (default) | 'b' | 'l' | 's' | 'a' | ...

Order for reading bytes in the file, specified as one of the strings in the table that follows. For bitn and ubitn precisions, machinefmt specifies the order for reading bits within a byte, but the order for reading bytes remains your system byte ordering.

'n' or 'native'

Your system byte ordering (default)

'b' or 'ieee-be'

Big-endian ordering

'l' or 'ieee-le'

Little-endian ordering

's' or 'ieee-be.l64'

Big-endian ordering, 64-bit long data type

'a' or 'ieee-le.l64'

Little-endian ordering, 64-bit long data type

By default, all currently supported platforms use little-endian ordering for new files. Existing binary files can use either big-endian or little-endian ordering.


c++中对于int,和float的数据,可以用下列方法进行位置互换:

((unsignedint *)data)[i] = ntohl(((unsignedint *)data)[i]);

参考:

http://cn.mathworks.com/help/matlab/ref/fread.html#inputarg_machinefmt

0 0