From: Rick DeNatale Date: 2007-06-18T04:36:19+09:00 Subject: Re: wite an integer to file as binary On 6/15/07, John Joyce wrote: > This one is always a stumper. > use the method to_s(2) > 5.to_s(2) > Converts 5 to base 2 (binary) as a string. > This is fine for output to a file! Except that the OP was looking to write the integer as 4 binary bytes. Array#pack is the way to go. > Alternatively, if you're looking to set binary write mode for Windows > (versus text mode. this is windows only) > there is binmode That doesn't afffect how data is written, it keeps windows from processing control characters and doing things like prematurely giving an end-of-file if the data contains a ctrl-D character. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/