Converting an integer to base 2

Kragen Sitaker kragen at pobox.com
Sat Dec 1 18:54:39 EST 2001


"Alves, Carlos Alberto - Coelce" <calves at coelce.com.br> writes:
> Yeah, it works. But not for n=0, when we get the wrong result '' intead '0'.

The representation of 0 as '0' is a special case.  You'll either have
to write special-case code for it or convert your recursive while loop
into a recursive do-while loop that always executes at least once.




More information about the Python-list mailing list