From: Martin DeMello Date: 2009-05-07T01:32:13+09:00 Subject: Re: Base62 encoding/decoding On Wed, May 6, 2009 at 2:26 AM, Todd Benson wrote: > > I don't think it's possible, though, unless you change your > intermittent base.  64 is there because "111111".to_i(2) is 63.  In it's definitely possible, just inefficient. first you set up your lookup table: > digits = (0..9).to_a.map(&:to_s) + ("a".."z").to_a + ("A".."Z").to_a > then you repeatedly find the lowest digit > out = "" > while n > 0 > rest, units = n.divmod(62) > out = digits[units] + out > n = rest > end martin