[Les Schaffer] > ... > so for my code, i will do > > def not4bit(x): > return ~x & 15 > > >>> not4bit(1) > 14 Les, if x is always in range(16), simply subtract it from 15. That is, def not4bit(x): assert 0 <= x < 16 return 15 - x It's twice as fast <wink>. or-15-times-as-slow-it's-hard-to-tell-ly y'rs - tim