compound assignment operator

V

Vasileios Zografos

Can someone please tell me what this assignment does?


iType |= EB_YMIN_ZMAX;
 
V

Victor Bazarov

Vasileios Zografos said:
Can someone please tell me what this assignment does?


iType |= EB_YMIN_ZMAX;

The same as

iType = iType | EB_YMIN_ZMAX;

with the exception that 'iType' is only evaluated once.

Victor
 
V

Vasileios Zografos

Victor said:
The same as

iType = iType | EB_YMIN_ZMAX;

with the exception that 'iType' is only evaluated once.

Victor

Trying not to sound too ignorant....
what does | do?
 
V

Victor Bazarov

Vasileios Zografos said:
Trying not to sound too ignorant....
what does | do?

It's what is known as "bitwise OR". Every pair of corresponding
bits in the operands is 'or'ed to produce the corresponding bit
in the result. Example:

010100101001110101 | 000100010101101001 => 010100111101111101

Victor
 
T

Thomas Matthews

Vasileios said:
Trying not to sound too ignorant....
what does | do?

Bitwise OR:

A B A OR B
--- --- ------
0 0 0
0 1 1
1 0 1
1 1 1

The bitwise-OR operator is often used to "set" bits.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top