From: Alex Young Date: 2007-06-15T20:39:19+09:00 Subject: Re: wite an integer to file as binary Jim flip wrote: > Simple problem but I'm not sure of an elegant solution, I can do it but > all a bit minging. > > Basically have a numeric value and want to write the value as a 4 byte > integer to a binary file. > > Thanks for any insight, > Jim. > File.open('output.bin', 'wb'){|f| f.write [val].pack('N') } Should do it, if you want network byte order. ri Array#pack if you want more info. -- Alex