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: Derick Centeno <email@hidden>
- Date: Sun, 24 Apr 2005 20:35:11 -0400
On Apr 24, 2005, at 7:35 PM, Justin Walker wrote:
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
--
In addition to what Justin noted regarding floats and doubles or rather
what is defined as a float (single-precision) or double
(double-precision) these values differ very greatly across computer
languages and the libraries those languages use. It is not unheard of
for many professionals to write their own libraries for these purposes
as what is provided in common or commonly available is just not
rigorous enough. This is something that becomes important when
precision IS an issue to consider.
Also of consideration is the fact that the media comprising the network
can become a issue as well especially as poor quality media tend to
scatter and confuse bit order and sometimes sequence, in different ways
at different states of degradation depending upon the media used. This
is also why the cheaper media requires more robust error correction
routines versus optical media (such as fiber optic cables) with
stronger data coherency can have error routines focussing upon the
maintenance of the beam coherency as opposed to the details of bit
order/sequence issues and the like.
There exist several courses involving electronics, computer programming
and other sciences including physics and mathematics all at very
advanced levels discussing the details of these issues - separately.
Just thought you should have a better idea of just how huge this
subject is.
If you do want to begin to approach these issues seriously for your own
reasons, interests and projects. Feel free to access: www.fatbrain.com
You'll be glad you did!
_______________________________________________
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