From: Mike Stok Date: 2006-06-09T11:49:36+09:00 Subject: Re: Converting 8 bytes to a Float On 8-Jun-06, at 10:39 PM, Harris Reynolds wrote: > Mike... thanks for the tip. My mileage is varying though... here > is the same irb session on my machine: > > irb(main):004:0> s = "" > => "" > irb(main):005:0> s << 64 << 53 << "\0" * 6 > => "@5\000\000\000\000\000\000" > irb(main):006:0> s.unpack('D') > => [6.73510288410787e-320] > > I'm not getting the clean result for some reason. > I'm on a PowerPC, and you're probably on an x86. Our endian-ness is different. D uses native format to unpack the bytes, if your bytes are laid out the way you said they are then you probably want to use G which is specifically "big endian". See http://en.wikipedia.org/wiki/Endian for more background. Hope this helps, Mike -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply.