• Advertisement

Archived

This topic is now archived and is closed to further replies.

Little endian to host?

This topic is 5191 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering if the sockets libraries (or any others) had a function to convert little endian to host that I overlooked (like ntohl)? Or should I roll my own? [edited by - Puzzler183 on February 8, 2004 9:11:07 PM]

Share this post


Link to post
Share on other sites
Advertisement
Something like that only not. Little endian -> local machine order is what I''m looking for, but apparently it doesn''t exist (big endian -> local does, ntohl and its peers).

Share this post


Link to post
Share on other sites
OK, as if I''m not making myself clear, I understand what htonl and ntohl do. I''m not a moron. Thye don''t do what I need though. They do local machine <==> network (big endian). I want local machine <==> little endian. Anyway, screw it, I''ll just roll my own.

Share this post


Link to post
Share on other sites
Why does endianness matter, anyway? Can''t you just say "I''ll store things in network byte order and reverse it to host order on load?"

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Probably for file format releated things (load and save from host to little endian file format).

To answer the specific question, you''ll have to roll your own. I don''t think any of the standard libraries have this functionality.

Share this post


Link to post
Share on other sites
No standard functions can do it. So you gotta write your own.

I wonder why though. Since the network (Big Endian) functions
are readily available, I expect most people would save binary
formats in Big Endian formats. I do.



Kami no Itte ga ore ni zettai naru!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Pretty much any "standard" file format that originated on x86 is little endian. .3ds is a good example. All multi-byte values are stored in little endian form.

Share this post


Link to post
Share on other sites

  • Advertisement