From: Brian Palmer Date: 2006-07-10T09:12:32+09:00 Subject: Re: Marshal's handling of floats On Jul 9, 2006, at 5:52 PM, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: Marshal's handling of floats" > on Sun, 9 Jul 2006 13:31:59 +0900, Brian Palmer > writes: > > |I was thinking about writing a patch to modify how Marshal handles > |floats, right now it dumps them using sprintf(3) and stores the > |resulting string in the Marshal stream. I'd like to see it handle > |floats the same way that Array#pack does: > | > |[400.53].pack('g').length == 4 > |[400.53].pack('G').length == 8 > | > |while > | > |Marshal.dump(400.53).length - 3 == 22 > |(and is slower, to boot) > | > |I want to make sure, though, that this would be an acceptable patch. > > 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. > Yes, that's a biggie. I didn't realize that ruby compiled on non-IEEE machines, but it makes sense now that I think about it. I think this is out of my league, I suppose it would require integrating a floating-point emulation library into ruby on such platforms, and having that library handle the packing/marshaling, or even using that library to back all Float objects on such platforms. I think that for my purposes it makes more sense to just write a separate Marshal-type extension library, since I only plan to target IA32, IA64 and Apple G4/G5. Thanks for the response! -- Brian