Author: Dieter Buerssner
Date: 09:21:18 12/05/02
Go up one level in this thread
On December 05, 2002 at 10:40:18, Miguel A. Ballicora wrote: >On December 05, 2002 at 08:27:54, Dan Newman wrote: > >>The b & -b trick relies on having twos-complement representation for > >In C, it works even with other "internal" representations. If the representation >is different, the C language will make it look like it. Only for unsigned types. >My point is that the trick is perfectly portable. > >>negative numbers. But it only works if b is signed (or perhaps with >>a cast to make it so). It can be done on unsigned b with an extra >>operation: b & (~b + 1). > >I works with unsigned too. Some compilers issue a warning, but it is >perfectly legal C. IMO, it is only strictly portable for unsigned types. Practically, it will probably work anywhere with signed types, too. Regards, Dieter
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.