Re: host to network byte order for floats, and float32_t?
site_archiver@lists.apple.com Delivered-To: Darwin-dev@lists.apple.com On Apr 24, 2005, at 7:35 PM, Justin Walker wrote: On Apr 24, 2005, at 16:29, Warwick Hall wrote: Newbie question 1: Yes and no. Newbie question 2: HTH. Regards, Justin You'll be glad you did! _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... 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, 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). 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. -- 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 This email sent to site_archiver@lists.apple.com
participants (1)
-
Derick Centeno