passing floats in inet socket-based IPC

Henry Spencer henry at zoo.toronto.edu
Fri Nov 30 09:46:51 AEST 1990


In article <1990Nov26.164122.6152 at noose.ecn.purdue.edu> luj at delta.ecn.purdue.edu (Jun Lu) writes:
>Is there a quick/neat way to passing floats in inet socket-based IPC, just
>like we "routinely" do for passing ints on "popular" architectures( with
>just some hton or ntoh conversions) ?

In a word, no.  There is too much diversity in floating-point formats to
admit of any graceful general solution that's also quick and simple.
About the best you can do is convert to IEEE format, since that conversion
is a no-op on increasingly many machines, and then deal with the byte
order in much the same way as for integers.  However, conversions to and
from IEEE format can be costly on non-IEEE machines.

ASCII is probably simpler unless you've got pre-canned IEEE conversions
(which I believe XDR does).
-- 
"The average pointer, statistically,    |Henry Spencer at U of Toronto Zoology
points somewhere in X." -Hugh Redelmeier| henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.unix.questions mailing list