FileIO class overview

FileIO is used to handle the endian problem. Most computer systems are big endian, but the main exception is Intel computers. Also, files are assumed to be in different types of endian format. For example, a NeXT/Sun soundfile is usually written in big endian format, wave files are written in little endian format regardless of the endianess of the computer. FileIO is publicly derived from the standard class fstream.

Most data types are larger than one byte. On big endian computers, the first byte encountered in the data storage area is the most significant byte, while on a little endian computer, the first byte encountered in the data storage area is the least significant byte. So if you think you are reading one type, but are actually reading another type, you will get a completely different number!

Take for example the number 779,316,836 as a 32-bit number, or an 4-byte number. In hexadecimal notation, this number is equivalent to 0x2e736e64. Pairs of hexadecimal digits are equivalent to one byte of storage area (each hexadecimal digit is equal to half a byte, or 4 bits). On a computer, this number can be stored in two ways according to the endianess of the computer:

Figure showing endian byte swapping

Note that the bits inside the byte do not change their ordering. See the WAVE soundfile format which has an example of the bytes found in a soundfile and how they are interpreted as little endian numbers.