From: Robert Dober Date: 2007-06-15T20:36:03+09:00 Subject: Re: wite an integer to file as binary On 6/15/07, 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. > A first idea - not tested - would be something like this class IO def write_int_4 int 4.times do putc int=int/256 end end end You gotta play around with alignment I am afraid, but the basics are there HTH Robert > -- > Posted via http://www.ruby-forum.com/. > > -- You see things; and you say Why? But I dream things that never were; and I say Why not? -- George Bernard Shaw