wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes |=  how does this operator work?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "|=  how does this operator work??" Watch "|=  how does this operator work??" New topic
Author

|= how does this operator work??

Fedry Kemilau
Ranch Hand

Joined: Aug 06, 2007
Posts: 44
Hi all,

My question is what i put in the title.

Thanks,
Fedry


Solve this code:<br /> <br />10010101100001111011011000010100000111001011011111100011110101111100110100001
Doug Connor
Greenhorn

Joined: Dec 11, 2007
Posts: 1
Don't you mean !=, which is "not equal to"?

Then you could do somthing like


[ December 11, 2007: Message edited by: Doug Connor ]
Balasubramanian Chandrasekaran
Ranch Hand

Joined: Nov 28, 2007
Posts: 215

Hi Fedry,
Hi all,

My question is what i put in the title.


If you mean '!=' its a not equal operator.But,when you want to check equality condition with Strings you cannot use this operator. There you have to use .equals() method.
Fedry Kemilau
Ranch Hand

Joined: Aug 06, 2007
Posts: 44
nope.

What i mean is |= not !=

Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3432
    
  12
Assuming it's not a typo, then it does a bitwise OR of the left and right hand variables and assigns the result to the left hand variable;
e.g this will set i to 13


Joanne
Fedry Kemilau
Ranch Hand

Joined: Aug 06, 2007
Posts: 44
Hi Joanne,

Thank you. Actually I don't understand about bitwise and how does the result become 13. I'll try to google it..

rgds,
Fedry
Balasubramanian Chandrasekaran
Ranch Hand

Joined: Nov 28, 2007
Posts: 215

Originally posted by Fedry Kemilau:
Hi Joanne,

Thank you. Actually I don't understand about bitwise and how does the result become 13. I'll try to google it..

rgds,
Fedry


Its just a Bitwise OR operation.As of previous thread take values

5 -> 0101
12 -> 1100

After applying OR operation you will get 1101 (which is 13).
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11169
    
  16

"bitwise or" means that you compare the two values literally bit by bit, and 'or' the result.

so, with i = 5, you have 0101
and with j = 12, you have 1100

or each bit colum giving 1101

which converts to 13


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
 
subject: |= how does this operator work??