From: "M. Edward (Ed) Borasky" Date: 2006-07-10T11:26:25+09:00 Subject: Re: Marshal's handling of floats Yukihiro Matsumoto wrote: > There are issues: > > * pack('g') would not work on non-IEEE floating machines. > * changing marshal format in incompatible way causes a lot of > troubles, so that it should be avoided if possible. > > I think we can merge it for 1.9 (if we address IEEE754 issue). > > matz. > A couple of questions: 1. How does XML handle floats? 2. How does YAML handle floats? 3. What is the format of a float when dumped using Marshal? My recommendation would be to dump floats as the hexadecimal representation of IEEE 64-bit formatted numbers. This is "almost universal" and occupies only 16 bytes. The alternative, dumping them in decimal in some "scientific" notation, takes more bytes and loses small, but noticeable, accuracy. Moreover, it does not capture IEEE's "Inf" and "NaN" values, which are very much part of the semantics and syntax of modern numeric processing. Non-IEEE architectures are very much the exception rather than the rule, and they can be expected to dump IEEE hex and read IEEE hex as a penalty for not adopting the standard. :) > > -- M. Edward (Ed) Borasky http://linuxcapacityplanning.com