Endians
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Endians
Implementations are likely have different internal representations. So, if you need to prepare some data for processing on a different implementation, you require a common format. The party preparing and encoding the data is said to serialize it, while the party decoding and processing it is said to deserialize it.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Endians
All right, I did not know the meaning of "serialization" in this context.
So to properly serialize or deserialize, one must know the internal representation. Or the library should supply some functions that are endian-aware (like ntohl() and relatives).
So to properly serialize or deserialize, one must know the internal representation. Or the library should supply some functions that are endian-aware (like ntohl() and relatives).
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Endians
Precisely.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Endians
Hi,
From this perspective you could say that endian problems are actually "lack of strong type checking" problems.
Cheers,
Brendan
Things like network packets and files are really arrays of bytes. If you treat them as arrays of bytes then you end up writing code (like "buffer[0] = myInt & 0xFF; buffer[1] = (myInt >> 8 ) & 0xFF;") to do type conversion correctly, and any endian problem disappears by accident.Hobbes wrote:So to properly serialize or deserialize, one must know the internal representation. Or the library should supply some functions that are endian-aware (like ntohl() and relatives).
From this perspective you could say that endian problems are actually "lack of strong type checking" problems.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.