This is not a specific question for any programming language. Say you have some files written on a large Andian machine, and you know how would you know if two single-byte values were written back-to-back? Big-endian reverses the order of 16, 32, and has 64 bit values, so how do you know if you need to read it as individual bytes?
For example, you can byte 0x11, then byte 0x22. If the file is 0x1122 then you read that on a small endian machine, you have to change it. So will you read it as 2211, or 1122? Will you know how?
Can it make any sense? I think I'm missing some basic basics.
There is no way to find out. This is the reason that formally specified file formats usually have an Anderenes mandate, or they provide an option (such as with Unicode, as MSN has been mentioned). In this way, if you are reading a file with a particular format, then you are already large-AADIAN, because it is a fact that in this format it is a special end.
Another good example of this - network protocols are usually large-endian, so if you are a small-endian processor talking to the internet, then you have to write the previous things if you have large- Endian, you do not have to worry about it. People use such things as they preprocess the things they write to the network so that their source code is identical on all machines. These functions are defined to do anything on Big Endian machines, but they flip byte on small-endian machines.
The key is that Endianes is a special property that represents architecture words, it is not a mandate to write them files in a certain way is; It just tells you that the instructions of architecture expects multi-byte words so that their bytes can be ordered in a certain way. A large endian machine can write a single byte sequence in the form of a little-endian machine, it can simply use some more instructions to do this, because it has to be re-ordered byte. The same is true for large-endian formats for small-endian machines.
Comments
Post a Comment