Choosing endianness for new data formats

355 views Asked by At

I need to create a new file format for use with multiple languages (including at least C++ & Java). The data being stored includes long lists of ints, and so I have to choose between little-endian and big-endian representation. While it's clear that both options can be made to work, (using Java LittleEndianDataInputStream and the like), it's not clear which option is better in terms of not creating headaches for programmers down the road.

What are the criteria favouring little-endian or big-endian?

2

There are 2 answers

1
missimer On

Big-endian is the network byte order. If for what ever reason you wished to send over a network socket instead of saving to a file and you used big-endian you could reuse some code.

2
gnasher729 On

You might consider using a textual format, like JSON. Just works, independent of endianness. Independent of word size. And parsers are available everywhere.