Network standard for floating point numbers? [summary]

Network standard for floating point numbers? [summary]

Post by Peter Johanss » Fri, 13 Aug 1993 13:22:39



[ I'm sorry I couldn't thread this to my original posting, but it
expired on our news server. ]


Quote:> I'm writing a network application where I need to pass double
> precision floating point values between many different architectures.
> Is there a good/standard way of doing this?

I would like to thank everyone who replied.  The nearly unanimous

gave the best summary:

Quote:> look into using xdr.  It is a set of functions associated with
> your rpc library.  xdr (external data representation) provides
> machine independent representation for all sorts of data structures
> including doubles.  Use xdr to translate to a "generic" representation,
> send that over then net, then use the xdr on the receiver's end
> to get that machine's native representation.

The xdr library seems to be available on every machine that supports
nfs and rpc -- just about everybody these days.  xdr uses the IEEE-754
standard for floating point, so the conversion from double is a no-op
for most machines.

Given the near universal usage of IEEE-754 representation, a fact I
was previously unaware of, I have decided to use it directly in my
protocol.  To keep things simple, I have decided not to use the xdr
library until such time as a conversion to IEEE-754 is actually
required.

Peter Johansson

 
 
 

Network standard for floating point numbers? [summary]

Post by Dan Po » Fri, 13 Aug 1993 22:06:32



Quote:>Given the near universal usage of IEEE-754 representation, a fact I
>was previously unaware of, I have decided to use it directly in my
>protocol.  To keep things simple, I have decided not to use the xdr
>library until such time as a conversion to IEEE-754 is actually
>required.

Even if all the target machines use IEEE floating point, the byte ordering may
differ between them, so it's better to use xdr from the very beginning.

Dan
--
Dan Pop
Tel:   +41.22.767.2335

Mail:  CERN - PPE, Bat. 21 1-023, CH-1211 Geneve 23, Switzerland

 
 
 

1. Network standard for floating point numbers?

I'm writing a network application where I need to pass double
precision floating point values between many different architectures.
Is there a good/standard way of doing this?

I have noticed that SGI and SPARC machines use the same internal
formats, and DEC (r2k, r3k) machines use the same format, but with the
byte ordering reversed.  I _could_ cast the double value to an
unsigned long and then send it through htonl() and ntohl(), but that
would cause all sorts of problems if I ever came across a machine that
used some other form of internal representation.

Any suggestions?

Please reply via e-mail; I will summarize to the net.

Peter Johansson

2. Want to use Linux server for school network w/internet, etc.

3. uniform floating point random number generator - summary

4. installing open LDAP on RH 8.0

5. egcs compatibility with IEEE floating point standard

6. Is tftp Still Happening?

7. support for ieee754 floating point standard under Linux

8. xmodmap?

9. Question on floating-point numbers

10. How to represent floating point numbers with German format

11. Expr and floating point numbers

12. How to sort floating point number

13. script to compare two floating point numbers or expressions