473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Why isn't there a logical XOR operator?

Of course one can get the effect with appropriate use of existing
operators, but a ^^ operator would make for nice symmetry (as well as
useful to me in something I'm working on). Am I the only one who
would find it useful?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #1
80 35005
Christopher Benson-Manica <at***@nospam.cyberspace.org> scribbled the following:
Of course one can get the effect with appropriate use of existing
operators, but a ^^ operator would make for nice symmetry (as well as
useful to me in something I'm working on). Am I the only one who
would find it useful?


You mean an operator that returns 1 if exactly one of its operands is
nonzero, and 0 otherwise? Yes, that would be useful. But forget about
the short-circuit semantics. Think about it and you'll see why.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
Nov 14 '05 #2
Joona I Palaste <pa*****@cc.helsinki.fi> scribbled the following:
Christopher Benson-Manica <at***@nospam.cyberspace.org> scribbled the following:
Of course one can get the effect with appropriate use of existing
operators, but a ^^ operator would make for nice symmetry (as well as
useful to me in something I'm working on). Am I the only one who
would find it useful?
You mean an operator that returns 1 if exactly one of its operands is
nonzero, and 0 otherwise? Yes, that would be useful. But forget about
the short-circuit semantics. Think about it and you'll see why.


Also if there were an unary ^ operator, we could write Japanese smileys
into our code. For example:
sashimi ^=^ kawaii;

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"War! Huh! Good God, y'all! What is it good for? We asked Mayor Quimby."
- Kent Brockman
Nov 14 '05 #3
nrk
Christopher Benson-Manica wrote:
Of course one can get the effect with appropriate use of existing
operators, but a ^^ operator would make for nice symmetry (as well as
useful to me in something I'm working on). Am I the only one who
would find it useful?

If you write your conditions to be all logical (that is avoid the if ( x )
style idioms), then using the existing xor operator would achieve exactly
the same thing as your proposed ^^, wouldn't it? I mean, there can be no
short-circuit evaluation of an xor operator.

-nrk.
--
Remove devnull for email
Nov 14 '05 #4
Joona I Palaste <pa*****@cc.helsinki.fi> spoke thus:
You mean an operator that returns 1 if exactly one of its operands is
nonzero, and 0 otherwise? Yes, that would be useful. But forget about
the short-circuit semantics. Think about it and you'll see why.


Hm, that's true. A ^^ B would have to evaluate A and B... I hadn't
thought of that, and I suppose that was a greater good than &/&&
and |/|| symmetry. Interesting.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #5
Joona I Palaste <pa*****@cc.helsinki.fi> spoke thus:
Also if there were an unary ^ operator, we could write Japanese smileys
into our code. For example:
sashimi ^=^ kawaii;


This assumes, of course, that C authors are familiar with the Japanese
emoticon paradigm ^_~

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #6
"nrk" <ra*********@devnull.verizon.net> wrote in message
news:ma*************@nwrddc01.gnilink.net...
Christopher Benson-Manica wrote:
Of course one can get the effect with appropriate use of existing
operators, but a ^^ operator would make for nice symmetry (as well as
useful to me in something I'm working on). Am I the only one who
would find it useful?

If you write your conditions to be all logical (that is avoid the if ( x )
style idioms), then using the existing xor operator would achieve exactly
the same thing as your proposed ^^, wouldn't it? I mean, there can be no
short-circuit evaluation of an xor operator.


(a ^^ b) would be something like ((!!a) != (!!b)). Could
be macrotized rather easily? Could the double bang be
reduced to a single bang on each side?

Nov 14 '05 #7
xarax <xa***@email.com> scribbled the following:
"nrk" <ra*********@devnull.verizon.net> wrote in message
news:ma*************@nwrddc01.gnilink.net...
Christopher Benson-Manica wrote:
> Of course one can get the effect with appropriate use of existing
> operators, but a ^^ operator would make for nice symmetry (as well as
> useful to me in something I'm working on). Am I the only one who
> would find it useful?
> If you write your conditions to be all logical (that is avoid the if ( x )
style idioms), then using the existing xor operator would achieve exactly
the same thing as your proposed ^^, wouldn't it? I mean, there can be no
short-circuit evaluation of an xor operator.

(a ^^ b) would be something like ((!!a) != (!!b)). Could
be macrotized rather easily? Could the double bang be
reduced to a single bang on each side?


Yes, ((!!a) != (!!b)) is equivalent to ((!a) != (!b)).

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"It was, er, quite bookish."
- Horace Boothroyd
Nov 14 '05 #8
Christopher Benson-Manica wrote:

Of course one can get the effect with appropriate use of existing
operators, but a ^^ operator would make for nice symmetry (as well as
useful to me in something I'm working on). Am I the only one who
would find it useful?


if (!!a ^ !!b) ....

c = !!a ^ !!b;

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #9
nrk
xarax wrote:
"nrk" <ra*********@devnull.verizon.net> wrote in message
news:ma*************@nwrddc01.gnilink.net...
Christopher Benson-Manica wrote:
> Of course one can get the effect with appropriate use of existing
> operators, but a ^^ operator would make for nice symmetry (as well as
> useful to me in something I'm working on). Am I the only one who
> would find it useful?
>

If you write your conditions to be all logical (that is avoid the if ( x
) style idioms), then using the existing xor operator would achieve
exactly
the same thing as your proposed ^^, wouldn't it? I mean, there can be no
short-circuit evaluation of an xor operator.


(a ^^ b) would be something like ((!!a) != (!!b)). Could
be macrotized rather easily? Could the double bang be
reduced to a single bang on each side?


Yes, as x xor y is the same as x' xor y'. However, while this is pretty
neat, I think it makes the code harder to comprehend than using a straight
xor operation on the logical conditions (maybe its me that gets confused
when seeing negation all over the place).

And for those who believe that the xor shouldn't be used in combining
logical conditions, there is one situation where I have found this to be
eminently useful: when processing command line arguments where two
different options are mutually incompatible, but atleast one of them must
have been specified.

-nrk.

--
Remove devnull for email
Nov 14 '05 #10
In <bv**********@chessie.cirr.com> Christopher Benson-Manica <at***@nospam.cyberspace.org> writes:
Of course one can get the effect with appropriate use of existing
operators, but a ^^ operator would make for nice symmetry (as well as
useful to me in something I'm working on).
Because ^ is good enough, given the fact that a logical XOR operator
couldn't have any shortcircuiting semantics. !a ^ !b yields exactly
the same result as the hypothetical ^^ operator. If a and b are already
logical expressions (i.e. expressions that evaluate to 0 or 1), a ^ b is
enough.
Am I the only one who would find it useful?


Are you still convinced that it would be useful?

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #11
On 3 Feb 2004 16:04:18 GMT, Joona I Palaste <pa*****@cc.helsinki.fi>
wrote:
xarax <xa***@email.com> scribbled the following:
"nrk" <ra*********@devnull.verizon.net> wrote in message
news:ma*************@nwrddc01.gnilink.net...
Christopher Benson-Manica wrote:
> Of course one can get the effect with appropriate use of existing
> operators, but a ^^ operator would make for nice symmetry (as well as
> useful to me in something I'm working on). Am I the only one who
> would find it useful?
>
If you write your conditions to be all logical (that is avoid the if ( x )
style idioms), then using the existing xor operator would achieve exactly
the same thing as your proposed ^^, wouldn't it? I mean, there can be no
short-circuit evaluation of an xor operator.

(a ^^ b) would be something like ((!!a) != (!!b)). Could
be macrotized rather easily? Could the double bang be
reduced to a single bang on each side?


Yes, ((!!a) != (!!b)) is equivalent to ((!a) != (!b)).


Huh? That's saying !!a is equivalent to !a. I think not.
Applying de Morgan's Theorem,
((!!a) != (!!b))
can be rewritten as:
! (!a == !b)
though.
-leor
Leor Zolman
BD Software
le**@bdsoft.com
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html
Nov 14 '05 #12

Yes, ((!!a) != (!!b)) is equivalent to ((!a) != (!b)).
Huh? That's saying !!a is equivalent to !a. I think not.


Oops, pounced too quick, sorry. Actually they're _all_ equivalent ;-)
-leor
Applying de Morgan's Theorem,
((!!a) != (!!b))
can be rewritten as:
! (!a == !b)
though.
-leor
Leor Zolman
BD Software
le**@bdsoft.com
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html


Leor Zolman
BD Software
le**@bdsoft.com
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html
Nov 14 '05 #13
Leor Zolman wrote:
Joona I Palaste <pa*****@cc.helsinki.fi> wrote:

.... snip ...

Yes, ((!!a) != (!!b)) is equivalent to ((!a) != (!b)).


Huh? That's saying !!a is equivalent to !a. I think not.
Applying de Morgan's Theorem,
((!!a) != (!!b))
can be rewritten as:
! (!a == !b)
though.


Huh? Look again. Write out a truth table or Karnaugh map.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #14
In <i8********************************@4ax.com> Leor Zolman <le**@bdsoft.com> writes:
On 3 Feb 2004 16:04:18 GMT, Joona I Palaste <pa*****@cc.helsinki.fi>
wrote:
xarax <xa***@email.com> scribbled the following:
"nrk" <ra*********@devnull.verizon.net> wrote in message
news:ma*************@nwrddc01.gnilink.net...
Christopher Benson-Manica wrote:
> Of course one can get the effect with appropriate use of existing
> operators, but a ^^ operator would make for nice symmetry (as well as
> useful to me in something I'm working on). Am I the only one who
> would find it useful?
>
If you write your conditions to be all logical (that is avoid the if ( x )
style idioms), then using the existing xor operator would achieve exactly
the same thing as your proposed ^^, wouldn't it? I mean, there can be no
short-circuit evaluation of an xor operator.

(a ^^ b) would be something like ((!!a) != (!!b)). Could
be macrotized rather easily? Could the double bang be
reduced to a single bang on each side?


Yes, ((!!a) != (!!b)) is equivalent to ((!a) != (!b)).


Huh? That's saying !!a is equivalent to !a. I think not.
Applying de Morgan's Theorem,
((!!a) != (!!b))
can be rewritten as:
! (!a == !b)
though.


And, guess what? ! (!a == !b) can be rewritten as !a != !b. However,
given that the OP wanted a logical XOR operator, !a ^ !b reflects his
intention better.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #15
"nrk" <ra*********@devnull.verizon.net> wrote in message
news:vJ***************@nwrddc02.gnilink.net...
xarax wrote:
"nrk" <ra*********@devnull.verizon.net> wrote in message
news:ma*************@nwrddc01.gnilink.net...
Christopher Benson-Manica wrote:

> Of course one can get the effect with appropriate use of existing
> operators, but a ^^ operator would make for nice symmetry (as well as
> useful to me in something I'm working on). Am I the only one who
> would find it useful?
>
If you write your conditions to be all logical (that is avoid the if ( x
) style idioms), then using the existing xor operator would achieve
exactly
the same thing as your proposed ^^, wouldn't it? I mean, there can be no
short-circuit evaluation of an xor operator.


(a ^^ b) would be something like ((!!a) != (!!b)). Could
be macrotized rather easily? Could the double bang be
reduced to a single bang on each side?


Yes, as x xor y is the same as x' xor y'. However, while this is pretty
neat, I think it makes the code harder to comprehend than using a straight
xor operation on the logical conditions (maybe its me that gets confused
when seeing negation all over the place).

And for those who believe that the xor shouldn't be used in combining
logical conditions, there is one situation where I have found this to be
eminently useful: when processing command line arguments where two
different options are mutually incompatible, but atleast one of them must
have been specified.


If you think that's bad, try the following with
A,B:{0,1}. First column is the intended operation.
Middle column is the arithmetic equivalent. Last
column is an alternative logical expression. The
variables A,B have values from the set {0,1}.
NOT(A): 1-A
A AND B: A*B : NOT(NOT(A) OR NOT(B))
A NAND B: 1-A*B : NOT(A) OR NOT(B)
A OR B: A+B-A*B : NOT(NOT(A) AND NOT(B))
A NOR B: 1-A-B+A*B : NOT(A) AND NOT(B)
A == B: 1+2*A*B-A-B : A XNOR B
A <> B: A+B-2*A*B : A XOR B
A < B: B-B*A : NOT(A) AND B
A > B: A-A*B : A AND NOT(B)
A <= B: 1-A+A*B : NOT(A) OR B
A >= B: 1-B+A*B : A OR NOT(B)

Nov 14 '05 #16
nrk <ra*********@devnull.verizon.net> writes:
Christopher Benson-Manica wrote:
Of course one can get the effect with appropriate use of existing
operators, but a ^^ operator would make for nice symmetry (as well as
useful to me in something I'm working on). Am I the only one who
would find it useful?

If you write your conditions to be all logical (that is avoid the if ( x )
style idioms), then using the existing xor operator would achieve exactly
the same thing as your proposed ^^, wouldn't it? I mean, there can be no
short-circuit evaluation of an xor operator.


The result will be an expression that breaks the first time you feed
it an operand that doesn't have the value 0 or 1. This will happen at
the most inconvenient possible time.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 14 '05 #17
nrk
Keith Thompson wrote:
nrk <ra*********@devnull.verizon.net> writes:
Christopher Benson-Manica wrote:
> Of course one can get the effect with appropriate use of existing
> operators, but a ^^ operator would make for nice symmetry (as well as
> useful to me in something I'm working on). Am I the only one who
> would find it useful?
>

If you write your conditions to be all logical (that is avoid the if ( x
) style idioms), then using the existing xor operator would achieve
exactly
the same thing as your proposed ^^, wouldn't it? I mean, there can be no
short-circuit evaluation of an xor operator.


The result will be an expression that breaks the first time you feed
it an operand that doesn't have the value 0 or 1. This will happen at
the most inconvenient possible time.


Read carefully. What I meant was that, you couldn't write:
if ( x ^ y ),
but you could write:
if ( (x != 0) ^ (y != 0) )

-nrk.
--
Remove devnull for email
Nov 14 '05 #18
Dan Pop wrote:

In <i8********************************@4ax.com> Leor Zolman <le**@bdsoft.com> writes:
On 3 Feb 2004 16:04:18 GMT, Joona I Palaste <pa*****@cc.helsinki.fi>
wrote:
xarax <xa***@email.com> scribbled the following:
"nrk" <ra*********@devnull.verizon.net> wrote in message
news:ma*************@nwrddc01.gnilink.net...
> Christopher Benson-Manica wrote:
> > Of course one can get the effect with appropriate use of existing
> > operators, but a ^^ operator would make for nice symmetry (as well as
> > useful to me in something I'm working on). Am I the only one who
> > would find it useful?
> >
> If you write your conditions to be all logical (that is avoid the if ( x )
> style idioms), then using the existing xor operator would achieve exactly
> the same thing as your proposed ^^, wouldn't it? I mean, there can be no
> short-circuit evaluation of an xor operator.

(a ^^ b) would be something like ((!!a) != (!!b)). Could
be macrotized rather easily? Could the double bang be
reduced to a single bang on each side?

Yes, ((!!a) != (!!b)) is equivalent to ((!a) != (!b)).


Huh? That's saying !!a is equivalent to !a. I think not.
Applying de Morgan's Theorem,
((!!a) != (!!b))
can be rewritten as:
! (!a == !b)
though.


And, guess what? ! (!a == !b) can be rewritten as !a != !b. However,
given that the OP wanted a logical XOR operator, !a ^ !b reflects his
intention better.


However, (!a != !b) reflects the intent of the code,
which is the logical relationship between a and b, better.

In any situation where I could write
if (!a ^ !b) {
I think I would rather write
if (!a != !b) {

Would you ever even write
if (!a ^ !b) {
?

That's the sort of thing that you would rather express as
if ((!a ^ !b) != 0) {
isn't it ?

--
pete
Nov 14 '05 #19
I officially nominate this question as a FAQ, and request that the first
update to the FAQ since February 7, 1999 be made.
--
#include <standard.disclaimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
Per the FCA, this address may not be added to any commercial mail list
Nov 14 '05 #20
On 3 Feb 2004 16:09:18 GMT, Da*****@cern.ch (Dan Pop) wrote:
Are you still convinced that it would be useful?


Yes, for the same reason as || and &&, albeit there's no shortcutting. It
makes it *obvious* that a purely boolean expression is involved. !a ^ !b
isn't obviously purely boolean; the central operator is not boolean.
--
#include <standard.disclaimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
Per the FCA, this address may not be added to any commercial mail list
Nov 14 '05 #21
Em Tue, 03 Feb 2004 17:05:14 +0000, CBFalconer escreveu:
Christopher Benson-Manica wrote: <snip>
if (!!a ^ !!b) ....

c = !!a ^ !!b;


Why !!a ? Doesn't this have the same effect of a? Like
if (a ^ b) ....
c = a ^ b;

Could you enlighten us?

--
Quidquid latine dictum sit altum viditur

Nov 14 '05 #22

On Tue, 3 Feb 2004, Dan Pop wrote:

Christopher Benson-Manica writes: [re: introducing a logical XOR operator]
Of course one can get the effect with appropriate use of existing
operators, but a ^^ operator would make for nice symmetry (as well as
useful to me in something I'm working on).


Because ^ is good enough, given the fact that a logical XOR operator
couldn't have any shortcircuiting semantics. !a ^ !b yields exactly
the same result as the hypothetical ^^ operator.


Possibly dumb, and possibly OT, question: What if 'a' and/or 'b' are
doubles with the IEEE value NaN, that screws up comparisons? Does
the !a^!b <==> a^^b equivalence still hold? (Or do NaN semantics already
make nonsense of certain operations?)
If a and b are already
logical expressions (i.e. expressions that evaluate to 0 or 1), a ^ b is
enough.
Am I the only one who would find it useful?


Are you still convinced that it would be useful?


Well, a logical xor operator wouldn't add anything to the capabilities
of the language, but then neither does having a special operator for
subtraction. I have, on occasion, run across situations where an XOR
operator would have been useful. Christopher mentioned command-line
argument parsing, such as:

[...]
switch (argv[i][j]) {
case 'K': KNRStyle = 1; break;
case 'A': AnsiStyle = 1; break;
}
[...]
if (KNRStyle ^^ AnsiStyle)
process(infp, outfp);
else
do_error("You must specify exactly one of -K, -A!\n");

Here the ^^ operator would capture the spirit of the condition better
than the != alternative, as well as being slightly more robust. The
suggested alternative,

if (!KNRStyle != !AnsiStyle)

is IMO so obfuscated as to be actually worse than simply enumerating
the cases:

if (KNRStyle && !AnsiStyle || AnsiStyle && !KNRStyle)
I also submit for consideration, as I've done before, the usefulness
of logical operators when dealing with pointers:

struct btnode {
int value;
struct btnode *left;
struct btnode *right;
};

int bt_IsUselessBranch(struct btnode *p)
{
return (p->value == 0) && (p->left ^^ p->right);
}

versus

return (p->value == 0) && (!(p->left) != !(p->right));

Of course, both cases are pretty ugly, here. But I haven't yet
come up with a good example. ;-)
And while I think it would have been cool if C had been designed
with a ^^ operator from the start, IMHO it's much too late now to
try adding it to the standard language. C doesn't need any more
syntax, and even if it did, I don't think the new syntax would find
many willing users. A new version of C would IMHO suffer the same
problems as C99 still suffers w.r.t. market share, only worse.
Now, a *new* language... :-)

-Arthur
Nov 14 '05 #23
José de Paula <jo***********@ig.com.br> scribbled the following:
Em Tue, 03 Feb 2004 17:05:14 +0000, CBFalconer escreveu:
Christopher Benson-Manica wrote: <snip>
if (!!a ^ !!b) ....

c = !!a ^ !!b;

Why !!a ? Doesn't this have the same effect of a? Like
if (a ^ b) ....
c = a ^ b; Could you enlighten us?


No, it's not the same effect. The outcome is mostly the same, but
there are differences.
Suppose a is 1 and b is 2. a ^ b will now be 3, which is different
from 0, and thus C considers it true.
However !!a will be 1, and !!b will also be 1, so !!a ^ !!b will be
0, and thus C considers it false.
The ! operator is defined as returning 1 if its operand is 0, or
returning 0 if its operand is anything other. !! is two ! operators
together, they return 0 if their operand is 0, or 1 if their operand
is anything other.
This is often used as a neat trick to "force" non-zero values to 1,
making sure bitwise operators work right in place of logical operators.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Make money fast! Don't feed it!"
- Anon
Nov 14 '05 #24

On Tue, 3 Feb 2004, [iso-8859-1] José de Paula wrote:

Em Tue, 03 Feb 2004 17:05:14 +0000, CBFalconer escreveu:
Christopher Benson-Manica wrote:

if (!!a ^ !!b) ....

c = !!a ^ !!b;


Why !!a ? Doesn't this have the same effect of a? Like
if (a ^ b) ....
c = a ^ b;

Could you enlighten us?


What is the value of 42?
What is the value of !!42?
What is the value of 42 ^ 6?
What is the value of !!42 ^ !!6?

-Arthur,
rhetorically
Nov 14 '05 #25
José de Paula wrote:
Em Tue, 03 Feb 2004 17:05:14 +0000, CBFalconer escreveu:

Christopher Benson-Manica wrote:


<snip>
if (!!a ^ !!b) ....

c = !!a ^ !!b;

Why !!a ? Doesn't this have the same effect of a? Like
if (a ^ b) ....
c = a ^ b;

Could you enlighten us?

Assume
a = 2;
b = 7;

Then
a ^ b == 2 ^ 7
== 5

which evaluates false in an if() statement

However
!a == 0

!!a == ! (!a)
== 1

!b == 0

!!b == ! (!b)
== 1

!!a ^ !!b == 1 ^ 1
== 0

which evaluates true in an if() statement
--
Lew Pitcher, IT Consultant, Application Architecture
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)

Nov 14 '05 #26
Gak!! Another fingercheck/brainfart

Lew Pitcher wrote:
José de Paula wrote:
Em Tue, 03 Feb 2004 17:05:14 +0000, CBFalconer escreveu:

Christopher Benson-Manica wrote:

<snip>
if (!!a ^ !!b) ....

c = !!a ^ !!b;


Why !!a ? Doesn't this have the same effect of a? Like
if (a ^ b) ....
c = a ^ b;

Could you enlighten us?


Assume
a = 2;
b = 7;

Then
a ^ b == 2 ^ 7
== 5

which evaluates false in an if() statement

which evaluates /true/ in an if() statement

However
!a == 0

!!a == ! (!a)
== 1

!b == 0

!!b == ! (!b)
== 1

!!a ^ !!b == 1 ^ 1
== 0

which evaluates true in an if() statement

which evaluates /false/ in an if() statement

--
Lew Pitcher, IT Consultant, Application Architecture
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)

Nov 14 '05 #27
Arthur J. O'Dwyer wrote:

On Tue, 3 Feb 2004, Dan Pop wrote:

Christopher Benson-Manica writes:

[re: introducing a logical XOR operator]
Of course one can get the effect with appropriate use of existing
operators, but a ^^ operator would make for nice symmetry (as well as
useful to me in something I'm working on).


Because ^ is good enough, given the fact that a logical XOR operator
couldn't have any shortcircuiting semantics. !a ^ !b yields exactly
the same result as the hypothetical ^^ operator.


Possibly dumb, and possibly OT, question: What if 'a' and/or 'b' are
doubles with the IEEE value NaN, that screws up comparisons? Does
the !a^!b <==> a^^b equivalence still hold? (Or do NaN semantics already
make nonsense of certain operations?)
If a and b are already
logical expressions (i.e. expressions that evaluate to 0 or 1), a ^ b is
enough.
Am I the only one who would find it useful?


Are you still convinced that it would be useful?


Well, a logical xor operator wouldn't add anything to the capabilities
of the language, but then neither does having a special operator for
subtraction. I have, on occasion, run across situations where an XOR
operator would have been useful. Christopher mentioned command-line
argument parsing, such as:

[...]
switch (argv[i][j]) {
case 'K': KNRStyle = 1; break;
case 'A': AnsiStyle = 1; break;
}
[...]
if (KNRStyle ^^ AnsiStyle)
process(infp, outfp);
else
do_error("You must specify exactly one of -K, -A!\n");

Here the ^^ operator would capture the spirit of the condition better
than the != alternative, as well as being slightly more robust. The
suggested alternative,

if (!KNRStyle != !AnsiStyle)

is IMO so obfuscated as to be actually worse than simply enumerating
the cases:

if (KNRStyle && !AnsiStyle || AnsiStyle && !KNRStyle)

I also submit for consideration, as I've done before, the usefulness
of logical operators when dealing with pointers:

struct btnode {
int value;
struct btnode *left;
struct btnode *right;
};

int bt_IsUselessBranch(struct btnode *p)
{
return (p->value == 0) && (p->left ^^ p->right);
}

versus

return (p->value == 0) && (!(p->left) != !(p->right));

Of course, both cases are pretty ugly, here.


.... without the extra parentheses:
return (p->value == 0) && (!p->left != !p->right);

explicit comparisons ...
((p->left == NULL) != (p->right == NULL));

With explicit comparisons against NULL,
as long as you have an odd number of nots, it's all the same.

((p->left == NULL) != (p->right == NULL));
((p->left != NULL) != (p->right != NULL));
((p->left != NULL) == (p->right == NULL));
--
pete
Nov 14 '05 #28
Em Tue, 03 Feb 2004 21:36:42 +0000, Joona I Palaste escreveu:
<snip>


I'm enlightened, thanks!

--
Quidquid latine dictum sit altum viditur
José - Threading The Long Path to Nerdvana

Nov 14 '05 #29
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
# Of course one can get the effect with appropriate use of existing
# operators, but a ^^ operator would make for nice symmetry (as well as
# useful to me in something I'm working on). Am I the only one who
# would find it useful?

#define logical_equiv(p,q) (!(p)==!(q))
#define logical_xor(p,q) (!(p)!=!(q))
#define logical_implies(p,q) (!(p)<=!(q))

--
Derk Gwen http://derkgwen.250free.com/html/index.html
I have no respect for people with no shopping agenda.
Nov 14 '05 #30
Kevin D. Quitt <KQ**********@IEEIncUNMUNG.com> wrote in message news:<gd********************************@4ax.com>. ..
I officially nominate this question as a FAQ, and request that the first
update to the FAQ since February 7, 1999 be made.


I agree.
Nov 14 '05 #31
Kevin D. Quitt <KQ**********@ieeincunmung.com> wrote:

Yes, for the same reason as || and &&, albeit there's no shortcutting. It
makes it *obvious* that a purely boolean expression is involved. !a ^ !b
isn't obviously purely boolean; the central operator is not boolean.


Then use the other exclusive-or operator: !a != !b.

-Larry Jones

I don't need to improve! Everyone ELSE does! -- Calvin
Nov 14 '05 #32
nrk <ra*********@devnull.verizon.net> writes:
Keith Thompson wrote:
nrk <ra*********@devnull.verizon.net> writes:
Christopher Benson-Manica wrote:
> Of course one can get the effect with appropriate use of existing
> operators, but a ^^ operator would make for nice symmetry (as well as
> useful to me in something I'm working on). Am I the only one who
> would find it useful?
>
If you write your conditions to be all logical (that is avoid the if ( x
) style idioms), then using the existing xor operator would achieve
exactly
the same thing as your proposed ^^, wouldn't it? I mean, there can be no
short-circuit evaluation of an xor operator.


The result will be an expression that breaks the first time you feed
it an operand that doesn't have the value 0 or 1. This will happen at
the most inconvenient possible time.


Read carefully. What I meant was that, you couldn't write:
if ( x ^ y ),
but you could write:
if ( (x != 0) ^ (y != 0) )


Yeah, that would work. (I think it's ugly, but it would work.)

If I really had a need for logical xor, I'd probably use a macro,
something like:

#define XOR(a, b) (!(a) ^ !(b))

(I think that's right.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 14 '05 #33
Keith Thompson <ks***@mib.org> spoke thus:
#define XOR(a, b) (!(a) ^ !(b))


Finding an XOR in code would be rather annoying (to track down the
header file where it's defined), I would think.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #34
Kevin D. Quitt <KQ**********@IEEIncUNMUNG.com> writes:
I officially nominate this question as a FAQ, and request that the first
update to the FAQ since February 7, 1999 be made.


For what it's worth, I've added a page to my own personal FAQ
list:
http://www.msu.edu/~pfaffben/writing...gical-xor.html
Anyone have anything to add or dispute?
--
"It would be a much better example of undefined behavior
if the behavior were undefined."
--Michael Rubenstein
Nov 14 '05 #35

On Tue, 3 Feb 2004, Ben Pfaff wrote:

For what it's worth, I've added a page to my own personal FAQ
list:
http://www.msu.edu/~pfaffben/writing...gical-xor.html
Anyone have anything to add or dispute?


Nit: "Far more rarely useful"? :) How about "far less often"?

And I would appreciate a clarification about how !a != !b interacts
with doubles, and some newbie no doubt would appreciate a clarification
about how it interacts with pointers. (!NULL == (int)1, !foo == (int)0;
but I am still waiting for someone more often correct than I to address
the question of !NaN.)

-Arthur
Nov 14 '05 #36
"Arthur J. O'Dwyer" <aj*@nospam.andrew.cmu.edu> writes:
On Tue, 3 Feb 2004, Ben Pfaff wrote:

For what it's worth, I've added a page to my own personal FAQ
list:
http://www.msu.edu/~pfaffben/writing...gical-xor.html
Anyone have anything to add or dispute?
Nit: "Far more rarely useful"? :) How about "far less often"?


Yes, that's much better phrasing. I will update it.
And I would appreciate a clarification about how !a != !b interacts
with doubles, and some newbie no doubt would appreciate a clarification
about how it interacts with pointers. (!NULL == (int)1, !foo == (int)0;
but I am still waiting for someone more often correct than I to address
the question of !NaN.)


I'm not sure what you'd like me to say about those cases. It
seems to me that, with the possible exception of NaN, they work
out okay.
--
"Some programming practices beg for errors;
this one is like calling an 800 number
and having errors delivered to your door."
--Steve McConnell
Nov 14 '05 #37
nrk
Ben Pfaff wrote:
"Arthur J. O'Dwyer" <aj*@nospam.andrew.cmu.edu> writes:
On Tue, 3 Feb 2004, Ben Pfaff wrote:

For what it's worth, I've added a page to my own personal FAQ
list:
http://www.msu.edu/~pfaffben/writing...gical-xor.html
Anyone have anything to add or dispute?


Nit: "Far more rarely useful"? :) How about "far less often"?


Yes, that's much better phrasing. I will update it.
And I would appreciate a clarification about how !a != !b interacts
with doubles, and some newbie no doubt would appreciate a clarification
about how it interacts with pointers. (!NULL == (int)1, !foo == (int)0;
but I am still waiting for someone more often correct than I to address
the question of !NaN.)


I'm not sure what you'd like me to say about those cases. It
seems to me that, with the possible exception of NaN, they work
out okay.


I am not sure if its in the C standard, but I believe NaN is to compare
unequal to any other number and even to NaN itself. Since ! yields 0 if
the operand is not equal to 0, if the above were true, one would expect
!NaN to yield 0.

-nrk.

--
Remove devnull for email
Nov 14 '05 #38
Ben Pfaff <bl*@cs.stanford.edu> writes:
Kevin D. Quitt <KQ**********@IEEIncUNMUNG.com> writes:
I officially nominate this question as a FAQ, and request that the first
update to the FAQ since February 7, 1999 be made.


For what it's worth, I've added a page to my own personal FAQ
list:
http://www.msu.edu/~pfaffben/writing...gical-xor.html
Anyone have anything to add or dispute?


Other than the URL, there's no mention of the common abbreviation "xor";
there probably should be.

Another thing I just noticed: <iso646.h> defines the following
macros:

and &&
and_eq &=
bitand &
bitor |
compl ~
not !
not_eq !=
or ||
or_eq |=
xor ^
xor_eq ^=

The "and", "or", and "not" macros refer to the logical operators, but
the "xor" macro refers to the bitwise operator. If a logical-xor "^^"
operator were added, the asymmetry would be painful.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 14 '05 #39
> Ben Pfaff <bl*@cs.stanford.edu> writes:
Kevin D. Quitt <KQ**********@IEEIncUNMUNG.com> writes:
I officially nominate this question as a FAQ, and request that the first
update to the FAQ since February 7, 1999 be made.


For what it's worth, I've added a page to my own personal FAQ
list:
http://www.msu.edu/~pfaffben/writing...gical-xor.html
Anyone have anything to add or dispute?


You say that logical xor is used much more rarely than logical and/or.
Question: Has anybody _ever_ found a situation where they would have
wanted a logical xor?
Nov 14 '05 #40
Christian Bau <ch***********@cbau.freeserve.co.uk> writes:
Ben Pfaff <bl*@cs.stanford.edu> writes:
Kevin D. Quitt <KQ**********@IEEIncUNMUNG.com> writes:

> I officially nominate this question as a FAQ, and request that the first
> update to the FAQ since February 7, 1999 be made.

For what it's worth, I've added a page to my own personal FAQ
list:
http://www.msu.edu/~pfaffben/writing...gical-xor.html
Anyone have anything to add or dispute?


You say that logical xor is used much more rarely than logical and/or.
Question: Has anybody _ever_ found a situation where they would have
wanted a logical xor?


Yes. I often use the bits of an `unsigned int' struct member to
represent a number of two-state attributes of an object, and
to test for (a combination of) attributes, I use the idiom

if (x->flags & FLAG_FOO) ...
if ((x->flags & FLAG_BAR) || (y->flags & FLAG_BAZ)) ...

where the tokens starting with FLAG_ are macros that expand to an
unsigned int constant expression with one and only one bit that is
set to 1. For symmetry reasons, I would prefer it if I could also
write

if ((x->flags & FLAG_BLAH) ^^ (y->flags & FLAG_BLUBB)) ...

IMHO, that would look nicer (i.e., more like similar expressions
involving && or ||) than the alternatives.

Martin
Nov 14 '05 #41
In article <bv*************@news.t-online.com>,
Martin Dickopp <ex****************@zero-based.org> wrote:
Christian Bau <ch***********@cbau.freeserve.co.uk> writes:
Ben Pfaff <bl*@cs.stanford.edu> writes:
> Kevin D. Quitt <KQ**********@IEEIncUNMUNG.com> writes:
>
> > I officially nominate this question as a FAQ, and request that the
> > first
> > update to the FAQ since February 7, 1999 be made.
>
> For what it's worth, I've added a page to my own personal FAQ
> list:
> http://www.msu.edu/~pfaffben/writing...gical-xor.html
> Anyone have anything to add or dispute?


You say that logical xor is used much more rarely than logical and/or.
Question: Has anybody _ever_ found a situation where they would have
wanted a logical xor?


Yes. I often use the bits of an `unsigned int' struct member to
represent a number of two-state attributes of an object, and
to test for (a combination of) attributes, I use the idiom

if (x->flags & FLAG_FOO) ...
if ((x->flags & FLAG_BAR) || (y->flags & FLAG_BAZ)) ...

where the tokens starting with FLAG_ are macros that expand to an
unsigned int constant expression with one and only one bit that is
set to 1. For symmetry reasons, I would prefer it if I could also
write

if ((x->flags & FLAG_BLAH) ^^ (y->flags & FLAG_BLUBB)) ...

IMHO, that would look nicer (i.e., more like similar expressions
involving && or ||) than the alternatives.


Yes, but have you actually needed it? In a real life program? Has it
happened that you wanted to take some action if exactly one of the flags
was set, but not both?

(A relatively common case would be where you believe that two conditions
that look different should have the same truth values and you use an
assert to either confirm this or find errors in the program or your
understanding of the program. But in this case I would prefer == or !=
because they express this clearer. For example, you might have two
pointers src and dst, and you know that if one is not NULL then the
other is not NULL as well, so you might write assert ((src != NULL) ==
(dst != NULL)) .)
Nov 14 '05 #42
Christian Bau wrote:
Ben Pfaff <bl*@cs.stanford.edu> writes:
Kevin D. Quitt <KQ**********@IEEIncUNMUNG.com> writes:

> I officially nominate this question as a FAQ, and request that the first
> update to the FAQ since February 7, 1999 be made.

For what it's worth, I've added a page to my own personal FAQ
list:
http://www.msu.edu/~pfaffben/writing...gical-xor.html
Anyone have anything to add or dispute?


You say that logical xor is used much more rarely than logical and/or.
Question: Has anybody _ever_ found a situation where they would have
wanted a logical xor?


(!(a) != !(b)) is adequate for the situation.

unsigned char bit_rev(unsigned char byte)
{
unsigned hi_mask, lo_mask;

hi_mask = ((unsigned char)-1 >> 1) + 1;
lo_mask = 1;
do {
if (!(byte & hi_mask) != !(byte & lo_mask)) {
byte ^= hi_mask | lo_mask;
}
hi_mask >>= 1;
lo_mask <<= 1;
} while (hi_mask > lo_mask);
return byte;
}

--
pete
Nov 14 '05 #43
Christian Bau <ch***********@cbau.freeserve.co.uk> writes:
In article <bv*************@news.t-online.com>,
Martin Dickopp <ex****************@zero-based.org> wrote:
Christian Bau <ch***********@cbau.freeserve.co.uk> writes:
> Ben Pfaff <bl*@cs.stanford.edu> writes:
> > Kevin D. Quitt <KQ**********@IEEIncUNMUNG.com> writes:
> >
> > > I officially nominate this question as a FAQ, and request that the
> > > first
> > > update to the FAQ since February 7, 1999 be made.
> >
> > For what it's worth, I've added a page to my own personal FAQ
> > list:
> > http://www.msu.edu/~pfaffben/writing...gical-xor.html
> > Anyone have anything to add or dispute?

You say that logical xor is used much more rarely than logical and/or.
Question: Has anybody _ever_ found a situation where they would have
wanted a logical xor?
Yes. I often use the bits of an `unsigned int' struct member to
represent a number of two-state attributes of an object, and
to test for (a combination of) attributes, I use the idiom

if (x->flags & FLAG_FOO) ...
if ((x->flags & FLAG_BAR) || (y->flags & FLAG_BAZ)) ...

where the tokens starting with FLAG_ are macros that expand to an
unsigned int constant expression with one and only one bit that is
set to 1. For symmetry reasons, I would prefer it if I could also
write

if ((x->flags & FLAG_BLAH) ^^ (y->flags & FLAG_BLUBB)) ...

IMHO, that would look nicer (i.e., more like similar expressions
involving && or ||) than the alternatives.


Yes, but have you actually needed it?


Yes. (Well, "needed" is too strong, but I would have liked to have it.)
In a real life program?
Not in a program I have been paid to write. In fact, not in a program
I have published yet. But in a program that is supposed to be applied to
a real life problem - it's not some kind of contrived example program.
Has it happened that you wanted to take some action if exactly one of
the flags was set, but not both?


One flag describes whether an object is "active" in some sense (for
example, a GUI element which can be "selected" or "unselected"). The
other flag describes what the former flag should be set to. If and only
if the former flag will change, i.e. the object is inactive and will be
activated or it is active and will be deactivated, some actions are to
be performed (e.g., a GUI element will be redrawn).

Martin
Nov 14 '05 #44
"Arthur J. O'Dwyer" <aj*@nospam.andrew.cmu.edu> wrote in message news:<Pi***********************************@unix41 .andrew.cmu.edu>...
Of course, both cases are pretty ugly, here. But I haven't yet
come up with a good example. ;-)
And while I think it would have been cool if C had been designed
with a ^^ operator from the start, IMHO it's much too late now to
try adding it to the standard language. C doesn't need any more
syntax, and even if it did, I don't think the new syntax would find
many willing users. A new version of C would IMHO suffer the same
problems as C99 still suffers w.r.t. market share, only worse.
Now, a *new* language... :-)


This is what I do when I need xor:

static inline int xor (int a, int b)
{
return a ? !b : b;
}

OR implement this with the binary '^' operator (I think it's slower
if you optimize).

The thing is that we couldn't do this with || and &&, because
these have early termination. And that's probably the reason for
their existance. In xor both must be evaluated.

And another problem is multiple xors. What happens then??

a ^^ b ^^ c ????

So xor is rather special
Stelios
Nov 14 '05 #45
stelios xanthakis wrote:
And another problem is multiple xors. What happens then??

a ^^ b ^^ c ????

So xor is rather special


No more than (e.g.) == or < in this respect as far as I can see.

Jeremy.
Nov 14 '05 #46

"Jeremy Yallop" <je****@jdyallop.freeserve.co.uk> wrote in message
news:sl*******************@hehe.cl.cam.ac.uk...
stelios xanthakis wrote:
And another problem is multiple xors. What happens then??

a ^^ b ^^ c ????

So xor is rather special


No more than (e.g.) == or < in this respect as far as I can see.


== is a short circuit though. The intention would be that ^^ would be a
short-circuit (otherwise I don't see the point) and as the others pointed
out you have to evaluate both sides to determine the result (therefore it
cannot short circuit).

What you could do is make ^& and ^| for NAND and NOR (former shorts if left
is zero, latter if left is one) and you'd have all four short-circuits ;-)

Well actually make ^& into ^^ since it's ambiguous with ^&varname, etc...so
you get

^^ = NAND
^| = NOR
|| = OR
&& = AND

Tom
Nov 14 '05 #47
ma****@freemail.gr (stelios xanthakis) writes:
And another problem is multiple xors. What happens then??

a ^^ b ^^ c ????


I guess it would have left-to-right associativity just like &&
and ||, i.e. behave like (a ^^ b) ^^ c. But even if it behaved
like a ^^ (b ^^ c), the result would be the same. Where do you
see a problem?

Martin
Nov 14 '05 #48

"Martin Dickopp" <ex****************@zero-based.org> wrote in message
news:bv*************@news.t-online.com...
ma****@freemail.gr (stelios xanthakis) writes:
And another problem is multiple xors. What happens then??

a ^^ b ^^ c ????


I guess it would have left-to-right associativity just like &&
and ||, i.e. behave like (a ^^ b) ^^ c. But even if it behaved
like a ^^ (b ^^ c), the result would be the same. Where do you
see a problem?


You cannot short circuit the XOR logical op. So what's the point?

Tom
Nov 14 '05 #49
"Tom St Denis" <to********@iahu.ca> wrote:
"Jeremy Yallop" <je****@jdyallop.freeserve.co.uk> wrote in message
news:sl*******************@hehe.cl.cam.ac.uk...
stelios xanthakis wrote:
And another problem is multiple xors. What happens then??

a ^^ b ^^ c ????

So xor is rather special


No more than (e.g.) == or < in this respect as far as I can see.


== is a short circuit though.


No, it's not.

a == b

needs to evaluate both a and b, and

a == b == c

needs to evaluate all three.

Richard
Nov 14 '05 #50

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: user | last post by:
Hi, Is it possible to override assignment, the way that '+' can be overridden for example? Thanks, Toby
14
by: lutorm | last post by:
Hi everyone, I'm trying to use istream_iterators to read a file consisting of pairs of numbers. To do this, I wrote the following: #include <fstream> #include <vector> #include <iterator> ...
5
by: kenny Nguyen | last post by:
Hi, Does anyone know the operator "=+"? If you do, what special method is related to this operator? Is it the __iadd__ method, but I think this is related to "+=" operator. Thanks, Kenny
67
by: carlos | last post by:
Curious: Why wasnt a primitive exponentiation operator not added to C99? And, are there requests to do so in the next std revision? Justification for doing so: C and C++ are increasingly used...
12
by: cody | last post by:
Why can I overload operator== and operator!= separately having different implementations and additionally I can override equals() also having a different implementation. Why not forbid...
33
by: SpreadTooThin | last post by:
Can these operators be overloaded? If so. How?
18
by: Ranganath | last post by:
Why is throw keyword considered as an operator?
6
by: Rudi | last post by:
Hello! I'm searching like a similar syntax for if(): int i=5; if (i in ) doSomething; e.g. enum TaskStates {Idle,Proc1,Proc2, ... ProcN}
19
by: C++Liliput | last post by:
I have a custom String class that contains an embedded char* member. The copy constructor, assignment operator etc. are all correctly defined. I need to create a map of my string (say a class...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.