Little endian vs. Big endian

3,222 views
Skip to first unread message

Thierry

unread,
Jul 8, 2008, 12:32:12 AM7/8/08
to Protocol Buffers
First of all, really happy to see such tools. Cannot wait to test it.
I look at the documentation but could not find anything regarding the
endianness of the binary data.

Can we use protocol buffer to exchange data between a little endian
and a Big endian system?

How do you handle float, double, etc..

Thanks

Thierry

Kenton Varda

unread,
Jul 8, 2008, 12:37:20 AM7/8/08
to Thierry, Protocol Buffers
On Mon, Jul 7, 2008 at 9:32 PM, Thierry <tfo...@gmail.com> wrote:
Can we use protocol buffer to exchange data between a little endian
and a Big endian system?

Yep.  On the wire, things are encoded little-endian, but the encoding and decoding routines will convert to and from your machine's format themselves, so you don't need to worry about it.
 
How do you handle float, double, etc..

Currently we assume all platforms use IEEE-754 floats and doubles.  If we want to add support for one that doesn't, it will just have to encode the floats as IEEE-754 on the wire, so that it is compatible with all other platforms.

Ryan Govostes

unread,
Jul 8, 2008, 1:51:23 AM7/8/08
to Protocol Buffers
Shouldn't they be encoded big endian, as that's network byte order?

Kenton Varda

unread,
Jul 8, 2008, 2:29:48 AM7/8/08
to Ryan Govostes, Protocol Buffers
On Mon, Jul 7, 2008 at 10:51 PM, Ryan Govostes <rgov...@gmail.com> wrote:
Shouldn't they be encoded big endian, as that's network byte order?

Arguably, yes.  However, most of Google's machines are little-endian so using that allowed for more optimization.

Auke Booij

unread,
Jul 10, 2008, 6:34:46 AM7/10/08
to Protocol Buffers
stupid standards :p

On Jul 8, 8:29 am, "Kenton Varda" <ken...@google.com> wrote:
Reply all
Reply to author
Forward
0 new messages