Binary, Hex, and Decimal string conversions

Robert Dailey rcdailey at gmail.com
Mon Aug 13 10:35:28 EDT 2007


Just curious Dick, why are you making your own to_base method? Doesn't the
source I provided in my earlier email give you all that you need? I was
hoping my source might be useful to a few people, even though it's pretty
trivial code.

On 8/12/07, Dick Moores <rdm at rcblue.com> wrote:
>
> At 07:04 PM 8/12/2007, Michael Bentley wrote:
>
> >On Aug 12, 2007, at 6:28 PM, Dick Moores wrote:
> >
> >>n = 12
> >>base = 36
> >>print to_base(n, base)
> >>==========================================
> >>This seems to work fine for n >= base, but not for n < base. For
> >>example, the code shown returns "c". Is my indentation wrong, or
> >>the code? It seems to me that the code should work for the general
> >>case, not just for n >= base.
> >
> >Isn't 'c' the correct answer?
>
> Yes, of course. Stupid of me.
>
> Dick
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070813/4d615aa2/attachment.html>


More information about the Python-list mailing list