From: Rob Lee Date: 2006-10-25T03:43:45+09:00 Subject: Re: Bitstuct and binary files Joel VanderWerf wrote: > Rob Lee wrote: >> puts f.read(3).unpack('H6').first.to_i(16) > > I think you want 'h' instead of 'H', and you need to reverse the > nibbles: > > puts f.read(3).unpack('h6').first.reverse.to_i(16) Ah, OK that works with my example script - thanks. However, that means the Bitstruct definition I gave is incorrect. The binary file I'm trying to modify correctly unpacks the integer using : f.read(3).unpack('H6').first.to_i(16) However, I'm really confused over what the Bitstruct definition should be to support this - do you have any suggestions ? Thanks -- Posted via http://www.ruby-forum.com/.