Converting integer to binary representation
Anton Vredegoor
anton at vredegoor.doge.nl
Wed Dec 17 07:30:36 EST 2003
More information about the Python-list mailing list
Wed Dec 17 07:30:36 EST 2003
- Previous message (by thread): Converting integer to binary representation
- Next message (by thread): Converting integer to binary representation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Mark Dufour <m.dufour at student.tudelft.nl> wrote: >I want to loop over the binary representation of numbers, for use in some >algorithm dealing with prime numbers. Of course, there are multiple ways of >doing this, but I like the clean: 'for power, bit in >enumerate(binary(number))', possible with the above code. Currently strings are immutable sequences of characters. So it would be possible to do what you write above if integers where seen as sequences of boolean in the same way. I guess it's obvious if you're Dutch: >>> list(10) >>> [True,False,True,False] Anton
- Previous message (by thread): Converting integer to binary representation
- Next message (by thread): Converting integer to binary representation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list