On Mon, 23 Oct 2000 rich+piclist@LCLOGIC.COM wrote: > 5 cycles: > > comf indf,w > addlw 1 > andf indf,w > subf indf,w > return > > The good old x&=-x trick! == Rich Nope! Close, but it doesn't quite work. (0 is not a power of 2) If you weren't worried about 0, then this would be 33% faster: decf indf,w andwf indf,w return Scott > > On Mon, 23 Oct 2000, Scott Dattalo wrote: > > > Date: Mon, 23 Oct 2000 22:04:20 -0500 > > From: Scott Dattalo > > Reply-To: pic microcontroller discussion list > > To: PICLIST@MITVMA.MIT.EDU > > Subject: [pic]: Challenge: power of two test > > > > Write a function that returns zero if INDF is a power of two, else returns > > non-zero. -- http://www.piclist.com hint: PICList Posts must start with ONE topic: "[PIC]:","[SX]:","[AVR]:" =uP ONLY! "[EE]:","[OT]:" =Other "[BUY]:","[AD]:" =Ads