Playing with binary in Python

While debuging an AVR microcontroller, you need to play with bits. After playing with my calculator I decided to find another way to decode bin/hex etc .. I found a good recipe on ASPN.

Now, this is a little reminder for people (like me) which doesn’t read binary op fluently.

# This will off the bits according to value
x &= ~(value) 

# Here a little reverse: This will set bits on according to value
x |= value

Have fun w/ bits :)

Related posts :

admin December 15th, 2005


One Response to “Playing with binary in Python”

  1. Diez B. Roggischon 15 Dec 2005 at 7:13 pm

    I’ve used python to generate IO-Port bit patterns for debugging the AVR in the simulator. Helped a great deal to solve some tricky timing issues.

Comments RSS

Leave a Reply