From: Markus Date: 2004-09-24T00:26:30+09:00 Subject: Re: negative numbers and binary formats > > >>>[-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". -- Markus