[Tutor] Re: How to convert an integer into a binary?
Wed, 8 Aug 2001 15:58:46 +0200
On Wed, Aug 08, 2001 at 08:43:20AM -0500, Christopher Smith wrote:
> email@example.com wrote:
> Thanks for the bit-operations approach! (Watch out for the trivial z=0
> case, though, which should return e= instead of .)
Yes *duck* silly me *patsch*
It inspired me to
> change the approach that I had taken when needing this function. Here's
> what I came up with:
> def d2b(numb,b=2):
> '''Returns a list containing the base b representation of
> the decimal number, big end first.
> while l>=b:
> return l
How beautyful :-)
> There's already a version on the Useless site. Coupling
> what you had (case for b==2) with the above might make for a good
> addition, though.
Greetings J"o! :-)
No matter how old a mother is, she watches her middle-aged children for
signs of improvement.
-- Florida Scott-Maxwell