Re: Logical XOR
- From: Michal Nazarewicz <mina86@xxxxxxx>
- Date: Fri, 21 Sep 2007 21:17:57 +0200
On Sep 21, 11:30 am, Martin Wells <war...@xxxxxxxxxx> wrote:
!!a != !!b
About three seconds after I sent that post I realised I cuda written:
!a != !b
fred.l.kleinschmidt@xxxxxxxxxx writes:
If a and b are always boolean values (0 or 1), just use
a^b
If they are not you can join those two techniques to form !a ^ !b which
is probably faster then !a != !b because no branching is used (at least
on some architectures).
But, I assume that if at least one of the values (say a) is boolean the
following will be even faster: ((unsigned)(((signed)a)-1)) & b. Not
sure if it's not implementation specific though. (If neither is boolean
replace a with !a). Disadvantage is that if b is not boolean this will
not produce a boolean value.
--
Best regards, _ _
.o. | Liege of Serenly Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +--<mina86*tlen.pl>---<jid:mina86*chrome.pl>--ooO--(_)--Ooo--
.
- References:
- Logical XOR
- From: Martin Wells
- Re: Logical XOR
- From: Martin Wells
- Re: Logical XOR
- From: fred . l . kleinschmidt
- Logical XOR
- Prev by Date: Re: comparison between signed and unsigned int
- Next by Date: Re: comparison between signed and unsigned int
- Previous by thread: Re: Logical XOR
- Next by thread: Re: Logical XOR
- Index(es):
Relevant Pages
|