Standard extensions (logical exclusive or)

Joe Orost joe at petsd.UUCP
Fri Nov 9 00:20:14 AEST 1984


<>
>Joseph Orost suggests a new operator ^^ such that
>
>	a^^b
>
>would be equivalent to
>
>	a? (b?0:1): (b?1:0)
>
>What is wrong with writing
>
>	a!=b
>
>for this purpose?

Sorry, this is not the same.  Take, for instance, a=3 and b=4.

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

Next take a=3 and b=0:

	a^b  = 3
	a!=b = 1
	a^^b = 1

Another expression for a^^b is (a==0)^(b==0).
Yet another one is (a!=0)^(b!=0).
And yes, you have to evaluate both a and b no matter what.

					regards,
					joe

--
Full-Name:  Joseph M. Orost
UUCP:       ..!{decvax,ucbvax,ihnp4}!vax135!petsd!joe
US Mail:    MS 313; Perkin-Elmer; 106 Apple St; Tinton Falls, NJ 07724
Phone:      (201) 870-5844



More information about the Comp.lang.c mailing list