From: Robert Klemme Date: 2004-09-24T01:09:36+09:00 Subject: Re: negative numbers and binary formats "Markus" schrieb im Newsbeitrag news:1095953157.5019.15.camel@lapdog.reality.com... > > > >>>[-7000000].pack("i").unpack("h*").shift.reverse.gsub(/^f+(?=f)/, '') > > > > 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) > > > > :-)) I deliberately choose #shift in order to make the array a bit > > smaller and remove all unnecessary references to the string - kind of GC > > paranoid. :-) > > But: > 1. the array can't be referenced after the first/shift returns > (since it was an anonymous link in a message chain), so the > whole array is subject to GC from that point > 2. shift can be significantly slower than first > 3. how do you know that shift isn't doing something like: > > def Array.shift > result = @hypothetical_primitive_array[0] > @hypothetical_primitive_array = @hypothetical_primitive_array[1..-1] > result > end > > ...in which case you'd still have the (scavengable) copy around > just as if you'd done it yourself? > > It only pays to be paranoid if you can trust yourself more than you can > trust "them". LOL Lession taken. Thanks! Of course you're right. Now I just need to find out who is "me" and "them"... robert