473,795 Members | 3,331 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what exactly does the operator |= ???

hello!!

I was looking at some code in C... and saw this "exotic" operator |=.

first time with it, what exactky does???

thanks in advance.
Erick->

Nov 16 '06 #1
37 2002
Erick-said:
hello!!

I was looking at some code in C... and saw this "exotic" operator |=.

first time with it, what exactky does???
See K&R2, page 50.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: normal service will be restored as soon as possible. Please do not
adjust your email clients.
Nov 16 '06 #2
yeah, that page is about flow control but I don´t think this is the
problem. Is not flow, is assigment.

this was the line:

*cmd |= newcmd;

greetings
Erick->


Richard Heathfield wrote:
Erick-said:
hello!!

I was looking at some code in C... and saw this "exotic" operator |=.

first time with it, what exactky does???

See K&R2, page 50.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: normal service will be restored as soon as possible. Please do not
adjust your email clients.
Nov 16 '06 #3
Erick-wrote:
hello!!

I was looking at some code in C... and saw this "exotic" operator |=.

first time with it, what exactky does???

The lvalue on the left is inclusive-OR'd with the expression on the
right, and the result is stored in the lvalue.


Nov 16 '06 #4
:( I don't follow it

do you have a little example?? please!!!

thanks a lot!

Erick->
james of tucson wrote:
Erick-wrote:
hello!!

I was looking at some code in C... and saw this "exotic" operator |=.

first time with it, what exactky does???


The lvalue on the left is inclusive-OR'd with the expression on the
right, and the result is stored in the lvalue.
Nov 16 '06 #5

Erick-a écrit :
yeah, that page is about flow control but I don´t think this is the
problem. Is not flow, is assigment.

this was the line:

*cmd |= newcmd;

greetings
Erick->
The | operator is the bitwise OR operator. Well, in the same way the
expression x += 1; is equivalent to the x = x +1;, the above mentionned
expression is equivalent to:

*cmd = *cmd | newcmd;

Thierry

Nov 16 '06 #6
thank you!!!!

Thierry Chappuis wrote:
Erick-a écrit :
yeah, that page is about flow control but I don´t think this is the
problem. Is not flow, is assigment.

this was the line:

*cmd |= newcmd;

greetings
Erick->

The | operator is the bitwise OR operator. Well, in the same way the
expression x += 1; is equivalent to the x = x +1;, the above mentionned
expression is equivalent to:

*cmd = *cmd | newcmd;

Thierry
Nov 16 '06 #7
Erick-wrote:
Richard Heathfield wrote:
>Erick-said:
>>hello!!

I was looking at some code in C... and saw this "exotic" operator |=.

first time with it, what exactky does???
See K&R2, page 50.

yeah, that page is about flow control but I don´t think this is the
problem. Is not flow, is assigment.

this was the line:

*cmd |= newcmd;
Pleas don't top-post. I put your reply at the bottom of the
message you replied to and I kept the attribution line (the first
line: Erick-wrote: ) at the top (so everyone knows who wrote
what and in what order).

|= is like +=, -= and so on. It means that the variable
(actually, lvalue) to the left of the operator will take a value
equal to its original value bitwise-OR-ed with the value on the
right of the operator, e.g. a|=b is equivalent with a=a|b.
--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
Nov 16 '06 #8

Nelu wrote:
Erick-wrote:
Richard Heathfield wrote:
Erick-said:

hello!!

I was looking at some code in C... and saw this "exotic" operator |=.

first time with it, what exactky does???
See K&R2, page 50.
yeah, that page is about flow control but I don´t think this is the
problem. Is not flow, is assigment.

this was the line:

*cmd |= newcmd;

Pleas don't top-post. I put your reply at the bottom of the
message you replied to and I kept the attribution line (the first
line: Erick-wrote: ) at the top (so everyone knows who wrote
what and in what order).

|= is like +=, -= and so on. It means that the variable
(actually, lvalue) to the left of the operator will take a value
equal to its original value bitwise-OR-ed with the value on the
right of the operator, e.g. a|=b is equivalent with a=a|b.
--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)

like this?

Nov 16 '06 #9
Erick-wrote:
Nelu wrote:
>Erick-wrote:
>>Richard Heathfield wrote:
Erick-said:

hello!!
>
I was looking at some code in C... and saw this "exotic" operator |=.
>
first time with it, what exactky does???
See K&R2, page 50.

yeah, that page is about flow control but I don´t think this is the
problem. Is not flow, is assigment.

this was the line:

*cmd |= newcmd;
Pleas don't top-post. I put your reply at the bottom of the
message you replied to and I kept the attribution line (the first
line: Erick-wrote: ) at the top (so everyone knows who wrote
what and in what order).

|= is like +=, -= and so on. It means that the variable
(actually, lvalue) to the left of the operator will take a value
equal to its original value bitwise-OR-ed with the value on the
right of the operator, e.g. a|=b is equivalent with a=a|b.
--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)


like this?
Yes, you can also snip the signatures. They don't contain any
information that is relevant to the discussion. You can also snip
other stuff that you don't think is relevant to a follow-up. Just
make sure to keep the attributions and follow-up levels untouched
(when you snip) so you don't mangle posters and follow-ups.

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
Nov 16 '06 #10

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

Similar topics

226
12717
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> d1 = {'a':1} >>> d2 = {'b':2} >>> d3 = {'c':3}
70
8915
by: Roy Yao | last post by:
Does it mean "(sizeof(int))* (p)" or "sizeof( (int)(*p) )" ? According to my analysis, operator sizeof, (type) and * have the same precedence, and they combine from right to left. Then this expression should equal to "sizeof( (int)(*p) )", but the compiler does NOT think so. Why? Can anyone help me? Thanks. Best regards. Roy
2
1374
by: Alexander Stippler | last post by:
Hi, I've got a question concerning iterators. I'm writing some container class and iterators upon it. I have to have typedef typex pointer; typedef typey reference; to be standard conforming. But what semantic requirements does the standard expose on type typey (and typex). If I define reference operator*(), does the object I return have to be (non-const) referencable or can I return
12
3304
by: Steven T. Hatton | last post by:
This is something I've been looking at because it is central to a currently broken part of the KDevelop new application wizard. I'm not complaining about it being broken, It's a CVS images. Such things happen. The whole subsystem is going through radical changes. I don't really want to say what I think of the code just yet. That would influence the opinions of others, and I really want to know how other people view these things,...
2
3509
by: Steven T. Hatton | last post by:
I'm still not completely sure what's going on with C++ I/O regarding the extractors and inserters. The following document seems a bit inconsistent: http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#1 Copying a file: WRONG WAY: #include <fstream> std::ifstream IN ("input_file"); std::ofstream OUT ("output_file");
17
3502
by: Anoob | last post by:
Can we consider () unary operator when calling a function, in exps eq. f(), ( 1 + 2). But when we call function f( 10 ) it is a binary operator. Even if we pass f( 10, 20) as we are using , operator there one operand will be there for ()? And Unary operators like !, +, -, ~, ... are said to be having associativity right to left which means that we can write, (but not allowed) 1. 2! 2. !2
24
2966
by: Romeo Colacitti | last post by:
Hi, Does anyone here have a strong understanding for the meanings of the terms "lvalue" and "rvalue" as it pertains to C, objects, and different contexts? If so please share. I've been reading several old posts/threads on the subject, and they never end with a conclusion (people keep correcting each other and disagreeing).
15
1854
by: Pranav | last post by:
class just{ public : int x; just(){ x=1234; } just(int i){ x = i;} ~just(){ cout << " Here We Are\n" ;} }; int main() {
2
1791
by: Peng Yu | last post by:
Hi, In the following code, the 'copy' member function works. But the '=' operator does not work. Can somebody let me know why a member function is different from an operator. Thanks, Peng #include <iostream>
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9037
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.