NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Serialization of binary floating point numbers



On Sat, 18 May 2019 22:14:24 -0500
"J. Lewis Muir" <jlmuir%imca-cat.org@localhost> wrote:

> On 05/17, Sad Clouds wrote:
> > A bit of a random question/thought - what is a good and portable
> > method of storing/transmitting binary floating point numbers?
> 
> Maybe heavier than you'd like, but Protocol Buffers has a double type:
> 
>   https://developers.google.com/protocol-buffers/docs/proto3#scalar
> 
> Another possibility is XDR which has IEEE float and IEEE double types:
> 
>   https://en.wikipedia.org/wiki/External_Data_Representation
> 
> Lewis

OK thanks for the pointers, so XDR is what RPC is using, and most
OSes seem to include it in their base system, so should be quite
accessible and portable.

Anybody knows of any advantages of Protobuf vs XDR? From what I can
see, with XDR it's quite simple, you call a function to convert to/from
external representation. With Protobuf you need to build special
protocol compiler, define message format in .proto file, then use
special compiler to encode the message, this sounds like a pain in the
ass. Why didn't they use XDR in the first place? Then there is this
blog https://reasonablypolymorphic.com/blog/protos-are-wrong/


Home | Main Index | Thread Index | Old Index