LinuxQuestions.org Operators *^ and >>
 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

 11-01-2004, 11:29 AM #1 GodSendDeath Member   Registered: Mar 2004 Posts: 71 Rep: Operators *^ and >> Hey everyone; I've seen in several C programs the use of *^ and >> to manipulate numbers. I've seen *^ in XOR applications and >> in computing checksums in packet headers. What does *^ and >> or << do? Any help would be appreciated -GSD
 11-01-2004, 11:53 AM #2 itsme86 Senior Member   Registered: Jan 2004 Location: Oregon, USA Distribution: Slackware Posts: 1,246 Rep: Not sure what *^ is but ^ is the XOR operator. you'd do something like some_int ^ some_other_int. XOR works like AND and OR but only returns true if both bits are different, so you get like: 0 ^ 0 = 0 0 ^ 1 = 1 1 ^ 0 = 1 1 ^ 1 = 0 Here's an example: 1011 1001 ------ 0010 >> and << are bit shift operators. >> will shift all the bits in the integer to the right a specified number of times and << will shift the bits left a specified number of times. For instance if you had: 0x59 (01011001 in binary) you could do 0x59 << 1 to shift all the bits to the left resulting in 10110010 (0xB2 in hex). Last edited by itsme86; 11-01-2004 at 11:59 AM.
 11-01-2004, 01:48 PM #3 wapcaplet LQ Guru   Registered: Feb 2003 Location: Colorado Springs, CO Distribution: Gentoo Posts: 2,018 Rep: I don't think *^ is a valid operator in C++; perhaps there is some way it can be read as a combination of two operators? I can't think of any situations where * would not have a right-hand operand, though. I'd be interested to see the context you saw it in. ^= is the operator for assigning a value using XOR. As itsme says, though >> is a bitshift operator; it is also overloaded with other meanings, such as when they're used for stream extraction and stream insertion: Code: ```cout << "Enter x: "; cin >> x;``` In C++, you can overload any operator to do anything you want; I'm sure there are other meanings for most operators. But AFAIK you can't create new ones. Last edited by wapcaplet; 11-01-2004 at 01:50 PM.
 11-01-2004, 09:10 PM #4 GodSendDeath Member   Registered: Mar 2004 Posts: 71 Original Poster Rep: Hey, thanks for all the replies. I wrote the symbol "^*" wrong, I mean "^=" and "*=". I had a feeling ^= was XOR operations. Thanks for the replies guys and thanks for clearing things up for me. -GSD
 11-01-2004, 09:47 PM #5 itsme86 Senior Member   Registered: Jan 2004 Location: Oregon, USA Distribution: Slackware Posts: 1,246 Rep: ^= and *= or shortcut asignment operators. If you had a = a * b you could write it as a *= b. If you had num1 = num1 ^ num2 you could write it as num1 ^= num2. It works with any binary operator. It's when you're doing = .

 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 Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post eshwar_ind Programming 17 10-25-2004 02:13 AM exodist Programming 1 04-24-2004 03:03 PM kamransoomro84 Programming 8 04-22-2004 10:46 PM linuxanswer Programming 3 12-14-2003 06:09 PM herbie_52 Programming 2 05-23-2003 07:36 AM

LinuxQuestions.org

All times are GMT -5. The time now is 12:40 AM.

 Contact Us - Advertising Info - Rules - Privacy - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -