From: Dave Wilson Date: 2003-12-26T06:08:19+09:00 Subject: Re: binary data Alwin Blok wrote: > However, I do have a question about binary handling. I'd like to write > binary data directly to a file. > I found that I can use myfile.write(["1001010100"].pack("B10")), but > i'd like to be able to write, for example 0b1001010100 directly to a > file. How do I do that, or else, are ther other useful ways to write > binary data to a file? I don't know of a more appropriate method, but what about class IO def raw_write bits bits = [bits.to_s].pack('B*') if bits.is_a? Fixnum write bits end end myfile.raw_write 0b1001010100 Dave