Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

problem in understanding the statement in c languagee

Status
Not open for further replies.

abhishekdixit

Full Member level 2
Full Member level 2
Joined
Dec 30, 2011
Messages
124
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Location
India
Visit site
Activity points
2,182
hello,
i have seen a c program in a article, in which a term
Code:
pwr_on_led=AYES^AYES;
is used.
here pwr_on_led is a variable & AYES=1. but here i am unable to understand to the meaning of expression"AYES^AYES;". in this expression what is the purpose of the symbol"^".
please help me..


with regards,
Abhishek Dixit
 

It means XOR. Exclusive ORing something with itself toggles it.

Keith

- - - Updated - - -

http://en.m.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B
 

Let me clarify: it is bitwise XOR, and the result of Exclusive ORing something with itself is always 0.
So, normally the expression AYES^AYES returns a zero value of the same type as AYES.
In other words, it is equivalent to pwr_on_led=0;

N.B.: I said normally because there can be some exceptions. For instance, if AYES is defined as a funcion with a directive like this:
#define AYES somefunction()
and each invocation returns different values. But situations like these should be avoided.

Regards

Z
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top