nethlek@tokyo.com (Mantorok Redgormor) writes:
[color=blue]
> Ben Pfaff <blp@cs.stanford.edu> wrote in message news:<87n09q3694.fsf@pfaff.stanford.edu>...[color=green]
> >
nethlek@tokyo.com (Mantorok Redgormor) writes:
> >[color=darkred]
> > > I was wondering if anyone knew a way to emulate
> > > ++i;
> > > Without the need of a loop, where it can be done by just a one liner?
> > > Or possibly two/three liner minus the need for a loop[/color]
> >
> > Perhaps
> > i ^= (i & ~-~i) | (~i & -~i);
> > Works for me for small "unsigned" i, at least. For greatest
> > obscurity, it could be written as
> > i^=i&~-~i|~i&-~i;
> > This is decipherable in a few minutes with _Hacker's Delight_ by
> > Henry Warren, which I used to construct it, but probably baffling
> > otherwise.[/color]
>
> is the latter portable across sign-magnitude, ones' complement,
> and two's complement?[/color]
Unsigned values don't have any of those forms. If you want to
use it for signed values, I suspect it will work on typical two's
complement systems, but not on sign-magnitude or ones' complement
systems.
--
"What is appropriate for the master is not appropriate for the novice.
You must understand the Tao before transcending structure."
--The Tao of Programming