How to convert a number to hex number?

Ron Adam rrr at ronadam.com
Wed Nov 9 20:56:38 EST 2005



Klaus Alexander Seistrup wrote:
> Ron Adam wrote:
> 
> 
>>I just happen to have been playing around with converting bases 
>>the last couple of days.  (idonowhy) ;-)
>>
>>Oh yeah,  I was thinking of using base62 to generate non-repeating 
>>id strings and wanted to try it out.
> 
> 
> Shameless plug:
> 
> Have a look at my bconv at <http://magnetic-ink.dk/14>.  While it 
> doesn't handle base 62, it handles bases 2..36 neatly.
> 
> Cheers,

I took a look, underneath it's pretty much the same as the routines we 
posted.

In any case it doesn't address the issue Bengt was refering to either, 
for which I agree could be improved in Python.  For example my hp 
calculator displays base two's compliment for negative binary, octs, and 
hex numbers, and displays -value for decimal numbers.  I think this is 
what he wants along with a prefix to indicate the base.

Cheers,
    Ron









More information about the Python-list mailing list