Alan Gauld wrote: > I'm playing with some bit twiddling code at present and started > to get some unexpected results which i eventually realized > were down to Python ints acting like signed ints in C (but > with a 'flexible' sign bit!) > > This led me to wonder if there is a way to get unsigned type > behaviour in Python? > > This could be very useful in bit twiddling scenarios, especially > now that Python is being used on RasberryPi type devices to > control Arduinos and the like. I had a quick hunt in the docs > but couldn't think of a way to fake it.
I think you have to apply a mask: >>> -2 & 0xff 254 _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor