Hacker's guide

Endianness

Some files contain numbers that have a fixed endianness, independent from the endianness of the CPU DeuTex happens to run on. These call for some special treatment, as the C language has no provision for reading and writing integers otherwise than in the native endianness. Mnemonic to remember the arguments order : the object that has a defined endianness is considered central and therefore always comes first. Here is some sample code and the result of running it.
fwrite_i32_be (stdout, 0x12345678);
fwrite_i32_le (stdout, 0x12345678);
fwrite_i16_be (stdout, 0xabcd);
fwrite_i16_le (stdout, 0xabcd);
12 34 56 78 78 56 34 12 AB CD CD AB