LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-09-2004, 06:45 PM   #1
linuxanswer
Member
 
Registered: Oct 2003
Distribution: woodY 3.0 stable
Posts: 61

Rep: Reputation: 15
some differences


anyone can explain me the differences beetwen

intf.ifr_flags |= IFF_PROMISC; and intf.ifr_flags ^= IFF_PROMISC;




?
 
Old 04-09-2004, 10:13 PM   #2
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
|= does a bitwise OR, and ^= does a bitwise XOR. It's easiest to explain on a binary level. When you OR 2 bits, if either bit is 1, the result is 1. E.G.

1 | 1 == 1
1 | 0 == 1
0 | 1 == 1
0 | 0 == 0

When you XOR 2 bits, the result is only 1 if only 1 of the bits is 1. For instance

1 ^ 1 == 0
1 ^ 0 == 1
0 ^ 1 == 1
0 ^ 0 == 0

In C/C++ the |= and ^= is similar to += in that

a |= b is the same as a = a | b, and a ^= b is the same as a = a ^ b.

Hope that helps some.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
what are the differences? LinuxPadawan Linux - General 10 07-27-2005 03:39 PM
Differences between 9.1 and 10 mikeymorgan Slackware 4 03-28-2005 04:42 AM
cp -a or cp -R differences shanenin Linux - Software 4 02-01-2004 10:44 PM
R and TM differences? mikeshn General 1 09-10-2002 08:01 PM
what are some differences between C and C++? Chooco Programming 9 06-07-2002 07:14 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration