Re: host to network byte order for floats, and float32_t?
Re: host to network byte order for floats, and float32_t?
- Subject: Re: host to network byte order for floats, and float32_t?
- From: Justin Walker <email@hidden>
- Date: Sun, 24 Apr 2005 16:35:37 -0700
On Apr 24, 2005, at 16:29, Warwick Hall wrote:
Newbie question 1:
There are ntohl htonl ntohs htons functions that translate between
host and network byte order for integer variables. Is there a need to
worry about network byte ordering for floating point numbers such as
float or double?
Yes and no.
Yes, because byte-order will certainly affect the value of a bit-string
being interpreted as a floating point number.
No, because what you are dealing with is a collection of macros used
for low-level networking, where floating point numbers don't intrude.
If you want to deal with floating point numbers in a higher-level
protocol, you are in a pretty hairy problem domain. There are
protocols (XDR, associated with Sun RPC, for one; Apollo's work, for
another).
Newbie question 2:
Also there are commonly defined integer value types like uint32_t or
int16_t (usually in stdint.h). Is there a float32_t (for float) or
float64_t (for double)?
Not really, AFAIK. Floats and doubles tend (in modern chip
architectures) to be represented using an IEEE-standard format; so the
commonly defined types *are* "float" (single-precision) and "double"
(double-precision). These have precise meanings in the standards, and
more-or-less common implementation limits in practice.
HTH.
Regards,
Justin
--
Justin C. Walker, Curmudgeon-At-Large
Institute for General Semantics
--------
Men are from Earth.
Women are from Earth.
Deal with it.
--------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden