From: Florian Gross Date: 2004-09-23T20:54:32+09:00 Subject: Re: negative numbers and binary formats Robert Klemme wrote: > After a bit experimenting I came up with this: >>>[-7].pack("i").unpack("h*").shift.reverse.gsub(/^f+(?=f)/, '') > > => "f9" > >>>[-7000000].pack("i").unpack("h*").shift.reverse.gsub(/^f+(?=f)/, '') > > => "f953040" > > Florian, what do you think? Very nice, thank you. I wasn't aware of the range limit at first. Only thing I would change is using .first instead of .shift. (For clarity) > Kind regards > robert More regards, Florian Gross